Open
Description
Thank you for all your help @JulianKingman
I may be wrong, but as far as i know, the previous state is suggested to stay unchanged but _.clone is a shallow copy of the state :
var objects = [{ 'a': 1 }, { 'b': 2 }];
var shallow = _.clone(objects);
console.log(shallow[0] === objects[0]);
// => true
ref: https://lodash.com/docs/4.17.4#clone
So when we are mutating newState
, are we mutating the previous state?
For example, if we are gonna modify the resources property of state, I would suggest:
newState = _.clone(state);
newRes = _.cloneDeep(state.resources);
newState.resources = newRes;
return newState;
which will distinguish the previous state and the new state, and tell the store that the resources property have been changed.
This may also raise the issue of #35 , i.e. persist-redux thinks the state or the property hasn't been changed, so it won't persist the state or the property to disk.
You might be interested in this discussion:
rt2zz/redux-persist#90
regards,
Metadata
Metadata
Assignees
Labels
No labels