When i worked with react-redux i updated the state like this:
case CartActionTypes.ADD_ITEM:
return {
...state,
cartItems: [...cartItems, { action.payload }];
};
Now i'm using reduxjs/toolkit with slices, etc.
Should i update the state in the same way or maybe using .push method like this:
export const cartSlice = createSlice({
name: 'cart',
initialState: initialState,
reducers: {
addItemToCart(state, action) {
state.cartItems.push(action.payload);
},
}
Should i always return the state like i did usin