I have a state object that looks like this:
PlaylistDictionary: {
someId: {
pages: [] // trying to push something to this array here
},
someId2: {
pages: [] // trying to push something to this array here
}, etc
}
I'm trying to update the "pages" array but I keep getting an error saying I'm mutating the state.. which I don't understand because if I'm making a copy of the state object with Object.assign... how am i mutating the state? thank you for any help
case types.ADD_PAGE_TO_PLAYLIST: {
let playlistDictCopy = Object.assign({}, state.playlistDict );
if ( !playlistDictCopy[ action.playlistId ].hasOwnProperty('pages') ) {
playlistDictCopy[ action.playlistId ].pages = [];
}
playlistDictCopy[ action.playlistId ].pages.push( action.pageId );
return Object.assign( {}, state, { playlistDict: playlistDictCopy } );
}