I am trying to set a part of the state inside a reducer but I need to access part of the initial state that is nested.
What I am trying to do:
return {
...state,
list: action.payload,
filter: action.params,
filter.totalPages : action.totalPages,
};
This however does not working, I have tried doing filter['totalPages'] and it also does not work. How and what is the best practice to do this?
filter.totalPages? Do you really want to use that value as a property name? That would be an odd choice based on the name. What do you expect the result to be? Can you provide an example?