redux-persist merges persistReducer and rootReducer Times error
const persistConfig = {
key: "root",
sessionStorage,
stateReconciler: autoMergeLevel2
};
/ / an error will be reported at this step
const persistedReducer = persistReducer (persistConfig, rootReducer);
function configureStore (initialState) {
const middleware = applyMiddleware(thunk);
const createStoreWithMiddleware = compose(middleware);
const store = createStoreWithMiddleware(createStore)(
rootReducer,
initialState,
persistedReducer
);
const persistor = persistStore(store);
//var store = createStore(rootReducer, initialState);
//module.hot webpack
if (module.hot) {
module.hot.accept("../reducers", () => {
const nextReducer = require("../reducers/index");
store.replaceReducer(nextReducer);
});
}
return {store, persistor};
}
module.exports = configureStore;
Cannot read property "type" of undefined
/ / the action in the source code has no value
if (action.type = _ constants.PERSIST) {
var _sealed = false;
var _rehydrate = function _rehydrate(payload, err) {
// dev warning if we are already sealed
if (false) console.error("redux-persist: rehydrate for "" + config.key + "" called after timeout.", payload, err);
// only rehydrate if we are not already sealed
if (!_sealed) {
action.rehydrate(config.key, payload, err);
_sealed = true;
}
};
timeout && setTimeout(function () {
!_sealed && _rehydrate(undefined, new Error("redux-persist: persist timed out for persist key "" + config.key + """));
}, timeout);