我使用 store.replaceReducer 加载异步模块reducer。
const reducers = store.reducers; // reducer dictionary to cache
if (reducers.indexOf(reducer) === -1 && reducer !== defaultReducer) {
reducers.push(reducer);
const reducerObj = {};
reducers.forEach((reducerItem) => {
Object.assign(reducerObj, reducerItem);
});
store.replaceReducer(combineReducers(reducerObj));
当事件 第一个模块中的某个操作, reducer 按预期调用。
但是当使用 replaceReducer 将新的缩减器附加到存储时,将再次调用先前的缩减器,并且每次都会在 replaceReducer 之后调用
我该如何解决这个问题?