Skip to content

Don't allow Redux store initiation on server side #286

@lizadaly

Description

@lizadaly

In an attempt to address #285 I hit a few surprising errors related to the window object not being available and the Redux store seeming uninitialized in the debug console.

I think PersistGate (which I removed) was effectively causing NextJS to skip rendering of child nodes on the server side, but that wasn't the intent of the component (which was instead just supposed to be waiting for the async local storage initiation to complete). I think I fundamentally misunderstood that the architecture of [[..chapter]].tsx meant it was initializing some things like Redux on the server, when they should be client-side only. In practice I think this has caused some weird behavior in dev mode when hot reloading though I'm not sure if it's affected production.

Either way, it should be more clear which parts of the framework are run server-side (ideally nothing that isn't story initialization). There shouldn't need to be guards around the window object existing for code that should only ever be executed client-side.

I consider this a bug even in single-player mode just because the code is relying on an unintended side effect of redux-persist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions