I believe that I have been modifying my state for quite some time now. I wanted to do the following and was wondering why it did not work:
case "SAVE_DATA_TO_PERSON" :
let newState = {...state, data: {start: action.payload.start, end: action.payload.end}};
return newState;
I am here creating a new object, take the old state, and add my new data. While it does seem to make a difference, it does not keep the data for long. After firing other actions this is just gone. I wonder why?
This is how I used to do it, and it seems to work:
case "SAVE_DATA_TO_PERSON" :
let newState = state;
newState.audio = {start: action.payload.start, end: action.payload.end};
return newState;
But here, it seems, I am modifying state.
I would just like to know whether my first solution is the correct one, and my second solution here is indeed modifying state.