인프런 커뮤니티 질문&답변
안녕하세요 질문이 있습니다.!
작성
·
341
답변 1
0
공통점이있어요
import React, {useCallback, useState} from "react"; 이 hooks은 안그러는데
import {useDispatch, useSelector} from "react-redux"; react-redux 훅이 안되는거같아요
그 혹시나해서 _app.tsx 에
export default wrapper.withRedux(MyApp); 이거 감싸줬는데 이런 문구가 뜨네요
4. WrappedApp은 withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined }로 새 스토어를 생성했습니다.
오류: 잘못된 후크 호출입니다. 후크는 함수 구성 요소의 본문 내부에서만 호출할 수 있습니다. 다음 이유 중 하나로 인해 발생할 수 있습니다.
1. React와 렌더러(예: React DOM)의 버전이 일치하지 않을 수 있습니다.
2. Hooks의 규칙을 위반할 수 있습니다.
3. React의 복사본이 두 개 이상 있을 수 있습니다.이것도 해봤는데
ReferenceError: window is not defined
at Object.<anonymous> (C:\Users\Quantum\IdeaProjects\openAPI\frontend\my-app\node_modules\react-dom\index.js:40:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18) 가 뜨네요...
기존 nodebird에도 똑같이 넣어봤는데 그건 안뜨는듯해요...
일단 _app.tsx 파일에서 withRedux(app) 에 withRedux 메소드를 인식을 못하는거였어요 그 다음에러가 또 나오네요 근데..
계속 엉켜서 그냥 기존 포맷으로 잡아야겠어요.. ㅋㅋ 역시 버전, 환경문제... 삽파는 구간 ㅠㅠ
제가 프론트는 제로초님 강의 따라해본 것 밖에없어서... 버전, 환경설정 맞추는게 힘드네요 프론트를 많이 안다루다보니...
버전, 환경설정 관련해서 팁이 있나요..ㅠ
그냥 기존에 잘 되어있는 소스 활용하시는 게 좋습니다. 그러면서 하나씩 버전을 올려보면서 문제 생겼을 때 해결하면서 넘어가야 합니다. 한번에 버전을 쫙 올려버리면 해결하기 어려워집니다.





Server Error
Error: 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.