Possible documentation bug.
MustSeeMelons opened this issue · 0 comments
MustSeeMelons commented
I need to use getServerSideProps
to fetch some data while in SSR. The docs propose such a solution:
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'});
});
I get an error telling me my return type is incorrect. After checking the types I end up with this code:
export const getServerSideProps = wrapper.getServerSideProps((store) => ({ req, res, ...etc }) => {
return new Promise<any>((resolve, reject) => {
console.log("2. Page.getServerSideProps uses the store to dispatch things");
store.dispatch({ type: "TICK", payload: "was set in other page" });
resolve({}); // void is not an option, I have to return something
});
});
Versions:
NextJS: 13.2.4
next-redux-wrapper: 8.1.0
react: 18.2.0
typescript: 5.0.2,
If I'm doing something wrong I can't figure it out. Is this workaround acceptable for the time being?