Redux throws Warning on dispatch:
Error: A state mutation was detected inside a dispatch, in the path:
roundHistory.2.tickets. Take a look at the reducer(s)
Okay i got it. Spreading an array of objects gives a new array but with links to same objects. To avoid the mutation, i added this line:
archive[i] = {...state.roundHistory[i]};
case 'ARCHIVE_TICKETS' :
var archive = [...state.roundHistory];
for (var i in archive) {
archive[i] = {...state.roundHistory[i]};
if (archive[i]._id === action.roundId) {
archive[i].tickets = action.data;
}
}
return Object.assign({}, state, {
roundHistory: archive
});