Closed kiranp11 closed 8 years ago
Hi @kiranp11,
Looks like your middleware is in the wrong order. If you re-write to the following it should be okay:
function (initialState = {}) {
const rootReducer = Redux.combineReducers([MDA.tourReducer])
const reducer = compose(
mergePersistedState()
)(rootReducer);
const createEnhancedStore = compose(
Redux.applyMiddleware(MDA.reduxThunkMiddleware),
persistState(storage, "mda")
)(createStore);
return createEnhancedStore(reducer)
}
In this snippet persistState
is applied first and applyMiddleware
second. Whereas in your code it's the other way around.
Ah! That was the issue. Thanks much for the help!
Hello,
I'm trying to use
redux-localstorage@rc
I'm facing an issue that an updated state is not being persisted immediately after it is emitted by a reducer.I went through the code and noticed that persistState is not happening via a subscribe to the store like it was in 0.4.0 but just before a new action is being dispatched using a middleware.
So the current state (in my case result of an async action ) is not persisted until another action is dispatched. What am I missing here?
My create store function looks like this:
Thanks in advance
Kiran.