Skip to content

shallowEqual

shallowEqual(a, b): boolean

Defined in: utils/shallowEqual.ts:11

Shallow equality for useStore selectors that build a new object or array on every call (s => ({ a: s.a, b: s.b }), s => s.items.filter(...)). Equal when both are Object.is, or both are arrays / plain objects with the same length or keys and Object.is-equal entries. One level deep only.

const { name, age } = useStore((s) => ({ name: s.user.name, age: s.user.age }), shallowEqual);
ParameterType
aunknown
bunknown

boolean