Closed mik-rom closed 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.
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}}}
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.
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:
However, when I look in the state and diff for that action in devtools it is displayed like this:
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?