使用@ ngrx / store弹出此错误:
index.js?4b23:19 State mutation is prohibited inside of reducers.
(anonymous) @ index.js?4b23:19
(anonymous) @ index.ts:54
rootReducer @ index.ts:70
_initialStateFactory @ ng2.ts?2a33:24
AppModuleInjector.createInternal @ module.ngfactory.js:425
NgModuleInjector.create @ ng_module_factory.js?95b1:132
NgModuleFactory.create @ ng_module_factory.js?95b1:100
(anonymous) @ application_ref.js?0421:340
ZoneDelegate.invoke @ zone.js?e3a6:229
onInvoke @ ng_zone.js?b62b:269
ZoneDelegate.invoke @ zone.js?e3a6:228
Zone.run @ zone.js?e3a6:113
NgZone.run @ ng_zone.js?b62b:138
PlatformRef_._bootstrapModuleFactoryWithZone @ application_ref.js? 0421:338
(anonymous) @ application_ref.js?0421:389
ZoneDelegate.invoke @ zone.js?e3a6:229
Zone.run @ zone.js?e3a6:113
(anonymous) @ zone.js?e3a6:509
ZoneDelegate.invokeTask @ zone.js?e3a6:262
Zone.runTask @ zone.js?e3a6:151
drainMicroTaskQueue @ zone.js?e3a6:405
ZoneTask.invoke @ zone.js?e3a6:336
main.browser.ts:18 TypeError: Cannot set property 'actions$' of undefined
at CatBibleEffects (catBible.effects.ts:15)
at combination (utils.ts?b1fc:23)
at index.js?39b4:125
at index.js?4b23:16
at index.ts:54
at rootReducer (index.ts:70)
at _initialStateFactory (ng2.ts?2a33:24)
at AppModuleInjector.createInternal (module.ngfactory.js:425)
at AppModuleInjector.NgModuleInjector.create (ng_module_factory.js?95b1:132)
at NgModuleFactory.create (ng_module_factory.js?95b1:100)
at application_ref.js?0421:340
at ZoneDelegate.invoke (zone.js?e3a6:229)
at Object.onInvoke (ng_zone.js?b62b:269)
at ZoneDelegate.invoke (zone.js?e3a6:228)
at Zone.run (zone.js?e3a6:113)
答案 0 :(得分:2)
当从reducer中捕获错误时,似乎会返回State mutation is prohibited inside of reducers
错误...这里是ngrx-store-freeze/dist/index.js
代码,其中返回此错误的catch
会生效...
function storeFreeze(reducer) {
return function (state, action) {
if (state === void 0) { state = {}; }
deepFreeze(state);
// guard against trying to freeze null or undefined types
if (action.payload) {
deepFreeze(action.payload);
}
var nextState;
try {
nextState = reducer(state, action);
}
catch (error) {
console.error('State mutation is prohibited inside of reducers.');
throw error;
}
deepFreeze(nextState);
return nextState;
};
}
exports.storeFreeze = storeFreeze;
因此,您的错误可能确实与状态被不恰当地改变有关,或者只是意味着未被捕获的错误会在调用减速器时传播出来......
答案 1 :(得分:1)
此错误与我的效果文件或我的操作文件无关。从相似的文件复制后,我忘了重命名reducer功能。这也导致对此reducer的调用在主根reducer文件中也被命名为错误。