• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

next-redux-wrapper 7.0.5 버전 질문있습니다.

21.11.29 22:27 작성 조회수 194

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({...}); // 이렇게 사용하지 않고  위와 같이 사용할 예정입니다.

```

답변 2

·

답변을 작성해보세요.

1

문제 없습니다~ 강좌 라이브러리 버전 업데이트는 공지사항을 참고하세요~

0

답변 감사합니다~