inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] React로 NodeBird SNS 만들기

리덕스 실제 구현하기

npm run dev 오류가 뜹니다

해결된 질문

774

정현영

작성한 질문수 7

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/ 들어갔더니

이런 오류가 뜨면서 안됩니다.

유저를 왜 읽지 못하는 걸까요?

오류 해결하고 싶습니다 ㅠ

 

react redux node.js express next.js

답변 2

0

정현영

삭제된 글입니다

0

제로초(조현영)

아예 복사붙여넣기를 해보세요. 오타는 눈으로는 안 찾아집니다.

0

정현영

다음강의에서 default: return state; 하라고 하셔서 하니까 오류 수정 됬어요 감사합니다!

0

제로초(조현영)

아.. 이거 리덕스 실제 구현하기 강의 강의노트 보시면 나와있습니다. ㅠㅠ

0

제로초(조현영)

리덕스가 제대로 연결되지 않은 것입니다. configureStore.js나 _app.js같이 리덕스 연결 관련 코드를 봐야합니다.

0

정현영

image

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"
  }
}

 

0

제로초(조현영)

https://github.com/ZeroCho/react-nodebird/tree/master/ch3/front

완성 코드는 여기인데 reducers 쪽까지 전부 확인해보세요. return같은 걸 빠뜨리셨을 수도 있습니다.

0

정현영

다 살펴봤는데 오타가 하나도 없어요ㅠ 넥스트랑 리액트 버전도 강사님과 똑같이 변경했는데 여전히 유저를 읽지 못했다고 뜨네요 어떻게 하면 좋을까요?

넥스트 버젼 질문

0

78

2

로그인시 401 Unauthorized 오류가 뜹니다

0

89

1

무한 스크롤 중 스크롤 튐 현상

0

175

1

특정 페이지 접근을 막고 싶을 때

0

103

2

createGlobalStyle의 위치와 영향범위

0

96

2

인라인 스타일 리렌더링 관련

0

91

2

vsc 에서 npm init 설치시 오류

0

146

2

nextjs 15버전 사용 가능할까요?

0

158

1

화면 새로고침 문의

0

121

1

RTK에서 draft, state 차이가 있나요?

0

153

2

Next 14 사용해도 될까요?

0

452

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

349

1

url 오류 질문있습니다

0

211

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

373

1

sudo certbot --nginx 에러

0

1275

2

Minified React error 콘솔에러 (hydrate)

0

470

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

247

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

327

1

npm run build 에러

0

518

1

front 서버 npm run build 중에 발생한 에러들

0

382

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

338

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

288

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

239

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

201

1