redux-persist合并persistReducer和rootReducer时报错
redux-persist合并persistReducer和rootReducer时报错
const persistConfig = {
key: 'root',
sessionStorage,
stateReconciler: autoMergeLevel2
};
//在这一步会报错
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
//源码中的这个action没有值
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论