인프런 커뮤니티 질문&답변
next-redux-wrapper 7.0.5 버전 질문있습니다.
작성
·
251
0
잠시 강의를 멈추고 질문합니다.
next-redux-wrapper 버전이 7입니다. npm 사이트 보고 참고하여 아래와 같이 사용하여 강의를 진행하려는데 문제가 있을까요?
```javascript
export const getServerSideProps = wrapper.getServerSideProps((store) => () => {
store.dispatch({
type: LOAD_MY_INFO_REQUEST,
});
store.dispatch({
type: LOAD_POSTS_REQUEST,
});
}); // 이 부분이 Home 보다 먼저 실행됨
```
참고 사이트: https://github.com/kirill-konshin/next-redux-wrapper
참고한 코드
```javascript
export const getServerSideProps = wrapper.getServerSideProps(store =>
({req, res, ...etc}) => {
console.log('2. Page.getServerSideProps uses the store to dispatch things');
store.dispatch({type: 'TICK', payload: 'was set in other page'});
}
);
// Page itself is not connected to Redux Store, it has to render Provider to allow child components to connect to Redux Store
const Page: NextPage<State> = ({tick}) => (
<div>{tick}</div>
);
```
```javascript
context.store.dispatch({...}); // 이렇게 사용하지 않고 위와 같이 사용할 예정입니다.
```




