In the application that we're building, after the user logs out, there's no way to reset the store.
We have tried setting it to undefined,null or an empty object(it crashes the app), but that doesn't help.
Any update?
You can add a resetStore action ?
@revskill10 We tried that, but it didn't make any change.
As a temporary solution you could do something similar to:
const store = createStore({
...,
setState: action((state, payload) => payload),
});
const initialState = store.getState();
// Later... reset store
store.dispatch.setState(initialState);
And if you would like it wrapped in an action...
let initialState = {}
const store = createStore({
...,
reset: action((state, payload) => ({
...initialState,
}),
});
initialState = store.getState();
// Later... reset store
store.dispatch.reset();
Most helpful comment
And if you would like it wrapped in an action...