Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible documentation bug. #548

Open
MustSeeMelons opened this issue Jun 14, 2023 · 0 comments
Open

Possible documentation bug. #548

MustSeeMelons opened this issue Jun 14, 2023 · 0 comments
Labels

Comments

@MustSeeMelons
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant