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

How to reset the store (7.0.0-rc.2)? #357

Closed
tkrotoff opened this issue Apr 29, 2021 · 2 comments
Closed

How to reset the store (7.0.0-rc.2)? #357

tkrotoff opened this issue Apr 29, 2021 · 2 comments

Comments

@tkrotoff
Copy link

Following this PR: #324
It's not possible anymore to re-initialize the store.

Why would you do that? When unit testing getServerSideProps() for example.

With 7.0.0-rc.1 it was possible to delete window[STOREKEY] to reset the store.



Why do you memoize the store variable?

// Memoize store if client
if (!store) {
store = createStore();
}

this makes it impossible to inject an empty store.

@kirill-konshin
Copy link
Owner

Dispatch an action and reset the store. The store is memoized on client to keep it between page transitions when working in a legacy mode (w/o _app).

@Jekins
Copy link

Jekins commented Jun 1, 2021

Dispatch an action and reset the store. The store is memoized on client to keep it between page transitions when working in a legacy mode (w/o _app).

I don't understand how to reset the store on initialization on server side. Because of this, the login data of the previous user remains on the server in the store. And before the hydration occurs, the server runs logic that erroneously uses the previous user's store.

UPD: solution for me: #337 (comment)

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

No branches or pull requests

3 participants