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

Problems with redux-persist v5 #7

Open
giacomocerquone opened this issue Dec 11, 2017 · 7 comments
Open

Problems with redux-persist v5 #7

giacomocerquone opened this issue Dec 11, 2017 · 7 comments

Comments

@giacomocerquone
Copy link

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:

createStore(
  rootReducer,
  undefined,
  compose(
    applyMiddleware(
      thunkMiddleware,
      loggerMiddleware,
    ),
    reduxReset('RESET_APP')
  )
)

What may be causing this issue?

@ritz078
Copy link

ritz078 commented Dec 29, 2017

@giacomocerquone did you find a solution to this ?

@DavitVosk
Copy link

I have the same problem here for "redux-persist": "5.4.0". Can you please help to find a solution

@giacomocerquone
Copy link
Author

giacomocerquone commented Feb 10, 2018

@ritz078 no, for now I made myself happy using handmade RESET actions

@DavitVosk
Copy link

DavitVosk commented Feb 10, 2018

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

@GlisboaDev
Copy link

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!

@milasevicius
Copy link

milasevicius commented May 28, 2019

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()
  }
}

@foloinfo
Copy link

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.

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

6 participants