Open giacomocerquone opened 6 years ago
@giacomocerquone did you find a solution to this ?
I have the same problem here for "redux-persist": "5.4.0". Can you please help to find a solution
@ritz078 no, for now I made myself happy using handmade RESET actions
Yes @giacomocerquone, I make it by hand as well and it works. But it would be better if this package could handle it itself as it has to do
I'm not using redux-reset
(implemented a solution myself), but came across the same issue.
It seems redux-persist
doesn't like 'reseting' the state.
We resolved the situation by pausing the persistor ((persistor.pause()
) before setting the store state, then resuming (persistor.persist()
) it right after reseting, and everything works fine.
So we get a flow like: pause persistence -> reset store state -> resume persistence.
Hope it helps!
When we reset our state and purge storage, state is not persisted anymore - running persistor.persist() solves this issue.
Example code:
export function logout() {
return async dispatch => {
dispatch({ type: 'RESET' })
await persistor.purge()
await persistor.persist()
}
}
I had the same issue.
It seems like { type: 'RESET' }
will remove the _persistor
state and it causes redux-persist not to persist anymore.
I found it will be persisted if you pass an initial state.
dispatch({
type: 'RESET',
state: {
_persist: { version: 1, rehydrated: true }
}
})
I hope this helps.
Hi, I believe this package has some issues with redux-persist v5. Basically it's like it resets the state but the redux-persist package for some reason doesn't write the updated state to the storage system (asyncstorage in my situation).
But if I create a reset action by hand (that brings the state to its initial state), it works correctly. I'm integrating your package like this:
What may be causing this issue?