강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

Ko Yun Hyuk님의 프로필 이미지
Ko Yun Hyuk

작성한 질문수

[리뉴얼] React로 NodeBird SNS 만들기

서버사이드렌더링 준비하기

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

```

답변 2

1

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

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

0

Ko Yun Hyuk님의 프로필 이미지
Ko Yun Hyuk
질문자

답변 감사합니다~

Ko Yun Hyuk님의 프로필 이미지
Ko Yun Hyuk

작성한 질문수

질문하기