reactjs - Changing a property of all the objects in dictionary full of objects without mutating the state -


to short.. i'm trying edit property (selected) in objects of dictionary.. no matter i'm mutating state. can explain me how , why mine not work?

i have state:

{   pagedict = {     someid1: { prop1: prop1value, prop2: prop2value}, etc     someid2: { prop1: prop1value, prop2: prop2value}, etc   },   playlistindex: 0,   playlists: [ someplaylistid1, someplaylistid2, etc ],   playlistdict: {     someplaylistid1: { prop1: prop1value, pages: [ someid1, someid2 ], etc }     someplaylistid2: { prop1: prop1value, pages: [ someid1, someid2 ], etc }   }  } 

i have reducer function:

case types.set_single_page_select: {   let pagedictcopy = object.assign( {}, state.pagedict );   let activeplaylistid = state.playlists[ state.playlistindex];   let activeplaylist = state.playlistdict[ activeplaylistid ];    ( let pageid of activeplaylist.pages ) {     let page = pagedictcopy[ pageid ];     page.selected = ( pageid == action.pageid );   }    return object.assign({}, state, {     pagedict: pagedictcopy   }); } 

edit: have immutability-helper well


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -