行动
import { createAction } from '@ngrx/store';
export const logOut = createAction('[APP] LOGOUT');
减速机
import { createReducer, on } from '@ngrx/store';
import * as LogoutActions from '../actions';
export const clearStateReducer = createReducer(
on(LogoutActions.logOut, state => {
return (state = undefined);
})
);
应用程序模块
StoreModule.forRoot(reducers, { metaReducers: [clearStateReducer] }),
我正在尝试在单击注销按钮时重置状态。我确实清除了本地存储,但我还需要清除 redux 状态。所以按照这个例子https://medium.com/@moneychaudhary/how-to-reset-the-state-or-clear-the-store-on-logout-in-ngrx-store-d2bd6304f8f3
但是我在元减速器上遇到错误,我需要一些帮助来解决这个问题。谢谢。我附上了错误截图