rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.94k stars 866 forks source link

Access to state in callback of persistStore #955

Closed jamievicary closed 5 years ago

jamievicary commented 5 years ago

After rehydration, I need to modify my state. But the state is not provided as an argument for the callback. How can I access my state after rehydration?

elzup commented 5 years ago

I do this

  const persistedReducer = persistReducer(persistConfig, reducer)
  const store = createStore(persistedReducer, composer)
  const persistor = persistStore(store, {}, () => {
    const state = store.getState()
  })
jamievicary commented 5 years ago

Thanks Elzup.