You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
});
});
I need to use
getServerSideProps
to fetch some data while in SSR. The docs propose such a solution:I get an error telling me my return type is incorrect. After checking the types I end up with this code:
If I'm doing something wrong I can't figure it out. Is this workaround acceptable for the time being?
The text was updated successfully, but these errors were encountered: