AuthReducer-reducer file
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;
dispatcher-dispatching action
const authDispatch = useDispatch();
authDispatch({ type: 'SIGN_IN'});
Store
const rootReducer = combineReducers({
user: AuthReducer
}); const store = createStore( rootReducer, compose(applyMiddleware(thunk)) );
Result
{isAuthenticated: false}
Result i want
{isAuthenticated: true}
How can I solve this error I am unable to solve this error, please help me...