This is the first time I'm seeing this happen, I've been running the app for a while now and I've not changed the reducer so I'm not sure what's wrong. I am creating a new state object using the spread op. and then assigning the value but getting the error listed.
CallStack:
- You attempted to set the key 'lastSeen' with the value ... on an Object that is meant to be immutable and has been frozen
- Error stack is throwOnImmutableMutation (deepFreezeAndThrowOnMutationInDev.js:64:8)
- My file line number shown below
The line number it points me to is the assignment of lastSeen.
const initial = {
...
};
const BleCommunicator = (state = initial, action) => {
let nextState = null;
switch (action.type) {
...
case c.DEVICE_DISCONNECTED:
nextState = {
...state
};
nextState[action.device.id].lastSeen = moment(); //<-- this is where it is erroring
delete nextState[action.device.id].rssi;
nextState.connectedDevices = _.remove(nextState.connectedDevices, action.device.id);
break;
...
return nextState;
}
EDIT: something that seems to be the cause is that I'm running an rx epic that is updating the values. They take the normal path through actions/reducer but the second time the epic is run (on timer) it fails to update the value. Is there something that could be happening under the hood that could cause me to be updating an old state?
EDIT2: This is only happening on Android. Here is a link to the object that is the state for the item being updated. https://gist.github.com/anwarhamr/4c3ebc8e2a3d5166c025fd1cf69a7e1c