动作
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);
})
);
app.module
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
但是我在metareducers上出错,我需要一些帮助来解决这个问题。谢谢。我已附上错误屏幕截图