I have two nested structures newState and newState1 .
But when I compare them, equals () or Immutable.is () returns false . The values ββin these structures are identical.
How to compare newState and newState1 correctly ?
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));
Code in JSFiddle: https://jsfiddle.net/z3xuagwm/
Slava minchonok
source share