inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

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

antd와 styled-components

Cannot read properties of null (reading 'useRef') 오류 질문

해결된 질문

2558

김호로록

작성한 질문수 1

0

강의에서 진행 된 요소 추가 전까진 정상 작동 되는 것 확인 했습니다. Menu 추가 후 아래와 같은 오류가 출력 됩니다.

 

 

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

1. You might have mismatching versions of React and the renderer (such as React DOM)

2. You might be breaking the Rules of Hooks

3. You might have more than one copy of React in the same app

See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

 

TypeError: Cannot read properties of null (reading 'useRef')

at useRef (C:\Users\sion\node_modules\react\cjs\react.development.js:1630:21)

at Object.render (C:\Users\sion\node_modules\antd\lib\menu\index.js:19:37)

at ReactDOMServerRenderer.render (C:\Users\sion\Documents\prepare\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:3535:44)

at ReactDOMServerRenderer.read (C:\Users\sion\Documents\prepare\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:3373:29)

at renderToString (C:\Users\sion\Documents\prepare\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:3988:27)

at Object.renderPage (C:\Users\sion\Documents\prepare\front\node_modules\next\dist\next-server\server\render.js:50:851)

at Document.getInitialProps (C:\Users\sion\Documents\prepare\front\.next\server\pages\_document.js:264:19)

at loadGetInitialProps (C:\Users\sion\Documents\prepare\front\node_modules\next\dist\next-server\lib\utils.js:5:101)

at renderToHTML (C:\Users\sion\Documents\prepare\front\node_modules\next\dist\next-server\server\render.js:50:1142)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

 

터미널에 찍힌 로그입니다.

react/react dom 버전은 동일함을 확인했고 16.14.0 버전 사용 중입니다.

 

구글링 중 react hook form을 인스톨 하라는 검색 결과가 있어 해당 패키지 설치 했습니다. 버전은 7.49.2 사용 중 입니다.

 

로컬에서 실행 된 화면입니다.

 

 

react redux node.js express next.js

답변 2

0

제로초(조현영)

antd 버전은 몇 버전 사용하시고 계신가요? antd 5버전은 제 강의와 사용법이 좀 다릅니다.

https://github.com/ZeroCho/react-nodebird/blob/master/intersection%2Ffront%2Fcomponents%2FAppLayout.js

 

0

인프런 AI 인턴

안녕하세요, 인프런 AI 인턴입니다.

“Cannot read properties of null (reading ‘useRef’)” 라는 오류와 관련하여 이전에 수강생분이 질문하신 유사한 내용의 답변을 찾아보았습니다. 아래 링크에서 관련 내용을 확인하실 수 있습니다. 특히, React 버전이 일치하는지, Hooks 사용 규칙을 잘 따르고 있는지 등을 점검해보시기 바랍니다.

또한, 해당 게시물에는 강사님의 추가적인 조언도 포함되어 있어 더 깊은 이해에 도움이 될 것입니다.

넥스트 버젼 질문

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