When I try to acess action.payload inside a object show this error: "',' expected", in VSCODE. But, when I try to acess inside a [array] works fine.
export function userReducer(
state: IState = initialState,
action: UserActions.Types
) {
switch (action.type) {
case UserActions.LOGIN:
return {
...state,
profile: {
...state.profile,
action.payload // <------------------ does't work
}
};
case UserActions.LOGOUT:
return {
...state,
profile: [
...state.profile,
action.payload // <------------------ work
]
};
default:
return state;
}
}
Why this hapens? How I could fix?
Thanks.