Comparison
Immutable updatevsShallow equality
Immutable update
you built a new array with the change in it instead of pushing onto the one you already had.
Producing a new value rather than mutating the existing one, so that a shallow comparison can detect the change. It is not an aesthetic preference in a component framework: mutation in place is invisible to change detection, so the update simply does not render. The cost is allocation and the awkwardness of deep updates, which is what libraries with a draft-based API exist to hide.
Full entry →Shallow equality
the comparison checked each top-level property and still said unchanged, because the nested object was mutated in place.
Comparing two objects by checking their own top-level properties with `===`, one level deep. It is what component memoisation and store selectors use, because it is cheap and predictable. It misses any change inside a nested value, which is precisely why immutable update patterns exist: they guarantee that a real change is visible at the top level.
Full entry →