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 have a stupid issue and I'm not sure if I'm doing something wrong, or there is a bug somewhere.
I have an app and I'm auto persisting the state and syncing with a server every X seconds. When I log out of the app - I would like to ideally - clear the store. This would signal my app that the user is not logged in and I show him the login screen.
purgeStoredState seems to work fine - I land in my then function and I do my redirect to login screen. Unfortunately, the store is not cleared yet. If I try to login - I'm immediately logged in with my old data. Now if I close the app and then restart it - the state is cleared?
Do I need to do anything specific to clear the state?
The text was updated successfully, but these errors were encountered:
compojoom
changed the title
Purge() doesn't clean the store until app refresh?
Purge() doesn't clear the store until app refresh?
Dec 17, 2016
purgeStoredState simply purges the state from storage, does not affect the state in redux itself. It sounds like what you want to do actually is reset redux to initial state. If you do this redux-persist will automatically store the reset state, and no purege will be necessary.
There are multiple ways to reset state in redux, the simplest of which is to make an action called RESET and implement it in your reducer(s). Another option if you do not want to have to toy with your reducers is to store initial state when the app loads, and then send a custom REHYDRATE action with the initial state. Something like:
I have a stupid issue and I'm not sure if I'm doing something wrong, or there is a bug somewhere.
I have an app and I'm auto persisting the state and syncing with a server every X seconds. When I log out of the app - I would like to ideally - clear the store. This would signal my app that the user is not logged in and I show him the login screen.
I'm trying this
purgeStoredState seems to work fine - I land in my then function and I do my redirect to login screen. Unfortunately, the store is not cleared yet. If I try to login - I'm immediately logged in with my old data. Now if I close the app and then restart it - the state is cleared?
Do I need to do anything specific to clear the state?
The text was updated successfully, but these errors were encountered: