파일상에 useMemo를 사용한 적이 없는데 로컬 호스트가 열리지 않았다.
경고
react.development.js:207 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.
에러
Uncaught TypeError: Cannot read properties of null (reading 'useMemo')
at useMemo (react.development.js:1648:1)
at Provider (Provider.js:12:1)
at renderWithHooks (react-dom.development.js:16305:1)
at mountIndeterminateComponent (react-dom.development.js:20074:1)
at beginWork (react-dom.development.js:21587:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
at invokeGuardedCallback (react-dom.development.js:4277:1)
at beginWork$1 (react-dom.development.js:27451:1)
at performUnitOfWork (react-dom.development.js:26557:1)
다시 pull 받아도 같은 오류가 났다.
팀원은 오류가 안나고 나만 나는 이유...?
해결
env. 파일에서 로컬 호스트 주소가 바뀌었는데
기존의 /3002 번으로 접속하니 서버를 불러오지 못했던 것!
Json 서버 열기
json-server --watch db.json --port 4000
4000으로 열어서 해결했다.
'React' 카테고리의 다른 글
리액트 동적으로 CSS 클래스 설정하기 (0) | 2022.08.11 |
---|---|
React Hooks 적용, Custom Hook과 React.lazy()와 Suspense를 이용하기 (0) | 2022.07.30 |
React Hooks useMemo (0) | 2022.07.28 |
React Diffing Algorithm 비교 알고리즘 (0) | 2022.07.28 |
React 심화 Virtual DOM (0) | 2022.07.27 |