jargon

Comparison

Deep equalityvsShallow equality

Deep equality

you compared the two API responses field by field, all the way down, to decide whether to update.

Recursively comparing every nested value to decide whether two structures are equivalent. It gives the answer people intuitively want, at a cost proportional to the size of the data — and on a hot path that comparison can exceed the render it was meant to avoid. Cycles, dates, maps and undefined-versus-missing keys all make correct implementations subtler than they look.

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 →

Related comparisons