Using React Immutable Assistant with Immutable.js

I am working on a flux and am considering using immutable.js to maintain state. I saw that this reaction provides its own helper for updating immutable objects ( http://facebook.imtqy.com/react/docs/update.html ), but I could not say how much it differs from the immutable native methods setIn and updateIn ( i.e. I can already compare objects with === for se if they are changed using setIn). Is there a reason to use a response helper with immutable.js? Is it just syntactic sugar?

TL; DR:

var map = Immutable.fromJS({bar: 'baz'}); map2 = React.addons.update(map, { bar: {$set: 'foo'} }); 

differs from

 var map = Immutable.fromJS({bar: 'baz'}); map2 = map.set('bar', 'foo'); 
+7
javascript reactjs reactjs-flux
source share
1 answer

React.addons.update does not work with Immutable.js values; It works with regular JavaScript objects and arrays .

 var map = { bar: 'baz' }; var map2 = React.addons.update(map, { bar: {$set: 'foo'} }); console.log(map2); // A plain JS object of value `{bar: 'foo'}` 

Types in Immutable.js are implemented using special data structures to improve performance and space; Obviously, regular JavaScript objects consumed and created by React.addons.update are not.

+8
source share

All Articles