zalmoxisus / remote-redux-devtools

Redux DevTools remotely.
http://zalmoxisus.github.io/monitoring/
MIT License
1.8k stars 138 forks source link

Some state changes are not displayed #77

Closed mik-rom closed 7 years ago

mik-rom commented 7 years ago

I got stuck on something I thought was a bug in my code but it turns out the devtools monitor doesn't display the state properly.

After I dispatch a specific action and print a property in the new state before I return it, it is displayed like this as it should:

console.log(newState.localWallposts)
{ '363755918678537':
  { '1492602002':
 { id: 1492602002,
 text: 'test',
  received: true,
  error: false,
_stamp: 1492602002,
user_id: 359346589177349,
realId: 365061224315545 } } }

However, when I look in the state and diff for that action in devtools it is displayed like this:

localWallposts (pin): {
363755918678537 (pin) : { } 
}

Same in the "Raw" tab.

I looked around and maybe it is related to this? https://github.com/zalmoxisus/redux-devtools-extension/issues/124 I'm really not sure though, I use a normal javascript object as far as I know.

Any ideas?

zalmoxisus commented 7 years ago

You can check if the data can be serialized via console.log(JSON.stringify(newState), JSON.stringify(newState.localWallposts)). Without a repro it's difficult to say what could be the problem.

mik-rom commented 7 years ago

It is being serialized properly. I was going to dispatch the action again to screenshot the empty object in the monitor at that exact point in time but now it is properly displayed for the first time. Very stange, I didn't change anything. I'll keep digging.

console.log(JSON.stringify(newState.localWallposts))
{"363755918678537":{"1492603568":{"id":1492603568,"text":"qqqqqq","received":true,"error":false,"_stamp":1492603568,"user_id":359346589177349,"realI
d":365065232233641}}}
mik-rom commented 7 years ago

I use a delete in another action that is triggered later. Is it possible that it has something to do with it, even though I copy the object with the spread operator before using delete?


var updatedLocalWallposts = {...state.localWallposts}
delete updatedLocalWallposts[eventId][key]
return { 
        ...state,
        localWallposts: {
          ...updatedLocalWallposts
        }
      }

UPDATE: Seems to have fixed itself after I changed to a different method of deleting a property. I have no idea why, I thought using the spread operator to copy an object is enough to remove all references to previous states.