-
카테고리
-
세부 분야
풀스택
-
해결 여부
해결됨
npm run dev 오류가 뜹니다
23.07.04 20:26 작성 23.07.04 21:07 수정 조회수 550
0
http://localhost:3000/에 뜬 오류
Server Error
TypeError: Cannot read properties of undefined (reading 'user')
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
components/AppLayout.js (15:52) @ eval
13 |
14 | const AppLayout = ({ children }) => {
> 15 | const isLoggedIn = useSelector((state) => state.user.isLoggedIn);
| ^
16 | // const { isLoggedIn } = useSelector(state => state.user);
17 |
18 | return (
Call Stack
AppLayout
components/AppLayout.js (15:36)
Show collapsed frames
터미널에 뜬 오류
TypeError: Cannot read properties of undefined (reading 'user')
at eval (webpack-internal:///./components/AppLayout.js:32:101)
at /Users/hyeonyeongjeong/Documents/2023project/nodebird/prepare/front/node_modules/react-redux/lib/hooks/useSelector.js:67:26
npm run dev를 하고
http://localhost:3000/ 들어갔더니
이런 오류가 뜨면서 안됩니다.
유저를 왜 읽지 못하는 걸까요?
오류 해결하고 싶습니다 ㅠ
답변을 작성해보세요.
0
정현영
질문자2023.07.05
app.js
import React from 'react';
import Head from 'next/head';
import PropTypes from 'prop-types';
import 'antd/dist/antd.css';
import wrapper from '../store/configureStore';
const NodeBird = ({ Component }) => {
return (
<>
<Head>
<title>NodeBird</title>
</Head>
<Component />
</>
);
};
NodeBird.propTypes = {
Component: PropTypes.elementType.isRequired,
};
export default wrapper.withRedux(NodeBird);
코드입니다 어떤 문제가 있을까요?
package.json은 이렇습니다
강의에서는 리액트-리덕스만 설치했던거 같은데
리덕스를 제가 설치했는데 괜찮을까요?
{
"name": "react-nodebird-front",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next"
},
"author": "winkberry",
"license": "ISC",
"dependencies": {
"@ant-design/icons": "^5.1.4",
"antd": "^4.24.10",
"next": "^9.5.5",
"next-redux-wrapper": "^6.0.2",
"prop-types": "^15.8.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-redux": "^8.1.1",
"redux": "^4.2.1",
"styled-components": "^5.3.10"
},
"devDependencies": {
"eslint": "^8.43.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
}
}
조현영
지식공유자2023.07.05
https://github.com/ZeroCho/react-nodebird/tree/master/ch3/front
완성 코드는 여기인데 reducers 쪽까지 전부 확인해보세요. return같은 걸 빠뜨리셨을 수도 있습니다.
정현영
질문자2023.07.06
다 살펴봤는데 오타가 하나도 없어요ㅠ 넥스트랑 리액트 버전도 강사님과 똑같이 변경했는데 여전히 유저를 읽지 못했다고 뜨네요 어떻게 하면 좋을까요?
답변 2