2017-01-30 73 views
0

使用@ NGRX /商店内这个错误弹出:状态突变禁止减速

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) 

回答

1

此错误无关,与我的影响文件或我的行动文件。从类似的文件复制后,我忘了重命名reducer功能。这也导致这个reducer的调用在主根reducer文件中被错误地命名。

2

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

感谢您指出这一点。这是一个与ngrx的错误,它不应该这样做,它应该显示底层的错误。 – Purrell