我有一个ngrx v8
样式化简器(使用 createReducer + on)需要对路由更改做出反应。
let myAcction = createAction('my action', prop<boolean>);
let reducer = createReducer(
initialState,
on(myAction, (state, prop) => ({...state, example=prop })),
on(ROUTER_NAVIGATION, (state, routeParams) => ({...state, example2:{...routeParams}}))
)
这无法编译,因为ROUTER_NAVIGATION
不是动作创建者:
“@ngrx/router-store/navigation”类型的参数不可分配给“ActionCreator>”类型的参数。类型 '"@ngrx/router-store/navigation"' 不可分配给类型 'FunctionWithParametersType'
它不适用于RouterNavigationAction
:
“boolean”类型的参数不能分配给“ActionCreator>”类型的参数
如何在 createReducer/on 函数中使用 ngrx/router-store 操作?我找不到为给定动作导出的动作创建者。
我会在他们的存储库中针对 ngrx 提出问题。同时,您可以通过在对象中使用令牌来绕过它:{ type: ROUTER_NAVIGATION }
因为这就是它在引擎盖下的工作方式。这并不理想,但在他们修复它之前它可以工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句