@samitouri / QOS-React / commits / 8f4d30737d

Updated Immutable Data Stuctures Docs (#9845)

* updated immutable data structures section * improved immutable clarifications * changes to example immutable code

Nick Kasten committed Jul 5, 2017 at 19:08 UTC 8f4d30737def9fa3456149826414643b5cbbe4bf
1 file changed +3 -1
docs/docs/optimizing-performance.md
+3 -1
@@ -380,10 +380,12 @@ Although `y` was edited, since it's a reference to the same object as `x`, this
380 const SomeRecord = Immutable.Record({ foo: null });
381 const x = new SomeRecord({ foo: 'bar' });
382 const y = x.set('foo', 'baz');
383 +const z = x.set('foo', 'bar');
384 x === y; // false
385 +x === z; // true
386 ```
387
386 -In this case, since a new reference is returned when mutating `x`, we can safely assume that `x` has changed.
388 +In this case, since a new reference is returned when mutating `x`, we can use a reference equality check `(x === y)` to verify that the new value stored in `y` is different than the original value stored in `x`.
389
390 Two other libraries that can help use immutable data are [seamless-immutable](https://github.com/rtfeldman/seamless-immutable) and [immutability-helper](https://github.com/kolodny/immutability-helper).
391