작성
·
809
0
/!\ You are using legacy implementaion. Please update your code: use createWrapper() and wrapper.withRedux().
TypeError: Cannot read property 'getState' of undefined
at C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-redux\lib\components\Provider.js:31:18
at Object.useMemo (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:1239:19)
at useMemo (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react\cjs\react.development.js:1521:21)
at Provider (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-redux\lib\components\Provider.js:30:42)
at processChild (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:3043:14)
at resolve (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:2960:5)
at ReactDOMServerRenderer.render (C:\dev\js\react-project\react-nodebird\ch1\front\node_modules\react-dom\cjs\react-dom-server.node.development.js:3435:22)
먼 짓을해도 똑같은 오류입니다.
답변 2
7
저도 최신버전으로 설치를 해서 따라가니 같은 에러가 있었는데 아래와 같이 수정하니 되네요
제 버전은: "next-redux-wrapper": "^6.0.2",
컴포넌트에 별도의 Provider 설정을 안해도 wrapper에서 자체적으로 Provider까지 래핑해주네요
import React from 'react';
import Head from 'next/head';
import PropTypes from 'prop-types';
import withRedux from 'next-redux-wrapper';
import AppLayout from "../components/AppLayout";
import reducer from "../reducers";
import {createStore} from "redux";
const NodeBird = ({Component}) => {
return (
<>
<Head>
<title>NodeBird</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/antd/4.3.3/antd.compact.css"/>
</Head>
<AppLayout>
<Component />
</AppLayout>
</>
);
}
NodeBird.propTypes = {
Component: PropTypes.elementType,
store: PropTypes.object,
}
export default withRedux((initialState, options) => {
const store = createStore(reducer, initialState);
return store;
})(NodeBird);
0
https://github.com/ZeroCho/react-nodebird/blob/master/ch8/front/package.json
next-redux-wrapper 등의 버전이 다른 것 같습니다.