【发布时间】:2021-08-29 18:16:19
【问题描述】:
AuthReducer-reducer 文件
const initialState = {
isAuthenticated: false,
}
const authReducer = (state = initialState, action: any) => {
switch (action.type) {
case 'SIGN_IN':
state = {
...state,
isAuthenticated: true,
}
break;
case 'SIGN_OUT':
state = {
...state,
isAuthenticated: false,
}
break;
default:
state = {
isAuthenticated: false,
}
}
return state;
}
export default authReducer;
调度员-调度动作
const authDispatch = useDispatch();
authDispatch({ type: 'SIGN_IN'});
商店
const rootReducer = combineReducers({
user: AuthReducer
}); 常量存储 = 创建存储( 根减速器, 撰写(应用中间件(thunk)) );
结果
{isAuthenticated: false}
我想要的结果
{isAuthenticated: true}
我该如何解决这个错误我无法解决这个错误,请帮助我...
【问题讨论】: