Inflearn Community Q&A
No author
This post's author information has been deleted.
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();
}
);0





위 같이 해보세요