I have 2 nested structures newState and newState1.
But when I compare their, equals() or Immutable.is() returned false. The values in these structures identical.
How to correctly compare newState and newState1?
var grid = {
editable: false,
widgets: [{
name: 'Some widget',
type: 'List',
defaultDataSource: 'daily',
dataSources: {}
}, {
name: 'Some widget1',
type: 'List',
defaultDataSource: 'daily',
dataSources: {}
}]
};
var state = Immutable.fromJS(grid);
var newState = state.updateIn(['widgets'], function (list) {
return list.push(Immutable.Map({
name: 'Some widget2',
type: 'List',
defaultDataSource: 'daily',
dataSources: {}
}));
});
var newState1 = state.updateIn(['widgets'], function (list) {
return list.push(Immutable.Map({
name: 'Some widget2',
type: 'List',
defaultDataSource: 'daily',
dataSources: {}
}));
});
console.log(state.toJS(), newState.toJS(), newState1.toJS());
console.log(newState.equals(newState1)); //false
Code in JSFiddle: https://jsfiddle.net/z3xuagwm/