강의

멘토링

로드맵

Inflearn Community Q&A

No author

This post's author information has been deleted.

[Renewal] Creating a NodeBird SNS with React

Preparing for server-side rendering

Cannot read property 'dispatch' of undefined

Written on

·

352

0

export const getServerSideProps = wrapper.getServerSideProps(async (context=> {
  context.store.dispatch({
    type: LOAD_USER_REQUEST,
  })
  context.sotre.dispatch({
    type: LOAD_POSTS_REQUEST,
  })
  context.store.dispatch(END)
  await context.sotre.sagaTask.toPromise()
})

위 코드를 실행했을 때

dispatch of undefined라는 오류가 뜹니다.

configureStore.js 에서 store와 dispatch의 log를 찍어보면 잘 나오는데 왜 저런 오류가 뜨는걸까요?

redux의 전은 6이에요.

Next.jsexpressnodejsreduxreact

Quiz

41% of people got it wrong. Give it a try!

Compared to Client-Side Rendering (CSR), what is the main advantage of Server-Side Rendering (SSR)?

Reduced development complexity

Improving initial loading speed and fast content display

Easy real-time data update

No browser compatibility issues

Answer 2

1

export const getServerSideProps = wrapper.getServerSideProps(
  (store) => async () => {
    store.dispatch({
      type: LOAD_MY_INFO_REQUEST,
    });

    store.dispatch({
      type: LOAD_POSTS_REQUEST,
    });

    // REQUEST 가 saga 에서 SUCCESS 될 때까지 기다려준다
    store.dispatch(END);
    await store.sagaTask.toPromise();
  }
);

위 같이 해보세요

zerocho님의 프로필 이미지
zerocho
Instructor

저분의 원인은 sotre 오타였습니다 ㅎㅎ

7버전에서는 올려주신 코드대로 하면 됩니다.

감사합니다

0

zerocho님의 프로필 이미지
zerocho
Instructor

redux말고 next-redux-wrapper 버전이 6 맞으신가요?

No author

This post's author information has been deleted.

Ask a question