useSelector(atom, selector, equals?)React hook (chem-rx/react): derive any value from an atom with a selector function and re-render only when the selected value changes. The optionalequalscomparator (defaults toObject.is) dedupes re-renders by content, so an atom that churns references on every update only re-renders the component when the selected slice is not equal. See useSelector.
- Removed
useSelectAtom. Migrate touseSelectorwith a selector function:useSelectAtom(atom, 'key')becomesuseSelector(atom, (s) => s.key).
- Optional
equalscomparator on every atom creation path:Atom(value, { equals }),atom.derive(fn, { equals }), andatom.select(key, { equals }). Supply a content comparator to dedup notifications by data instead of identity. See Equality & change detection. Atom()'s second argument now also accepts an options object ({ readOnly?, equals? }) in addition to the legacyreadOnlyboolean.- Exported
Equals<T>andAtomFactoryOptions<T>types.
-
Every atom now decides whether to notify subscribers using an equality comparator that defaults to
Object.is:- A base atom no longer re-emits when
next()is called with anObject.is-equal value (previously everynext()notified). deriveno longer re-emits when its computed output isObject.is-equal (previously it re-emitted on every parent update).selectandcombineare unchanged in practice (alreadyObject.is).
Migration: pass
equals: () => falseto restore the previous always-notify behavior. - A base atom no longer re-emits when