4 ms·
That's only true if you exclusively use Immutable objects for collections and scalars for individual values, if you pass a date as a prop it's not going to work
by andrewingram 11y ago
That's only true if you exclusively use Immutable objects for collections and scalars for individual values, if you pass a date as a prop it's not going to work.
> new Date(0) === new Date(0)
<- false
- masklinn 11y agoThe same problem exists for Immutable collections: > Immutable.List.of(1) === Immutable.List.of(1) < false = $3 which is why Immutable.is exists.
- scotty79 11y agoShould we use Immutable.is instead of == in shouldComponentUpdate() ?
- masklinn 11y agoDepends the semantics you want? `===` is O(1) but it will miss if the collection was altered or replaced in a value-preserving manner, so it will never match if your input is computed (e.g. mapped from a section of the application state). `Immutable.is` is more expensive (since it has to walk both collections) but it will allow skipping updates for equal inputs.