shallowEqual

function
react/src/utils/shallowEqual.ts:20
signature
shallowEqual<T>(a, b): boolean

Shallow object equality using Object.is per-key. Useful as the isEqual argument for useAtomicProp and useAtomicProps when the derived value is a plain object. Also available from the object returned by createHooks and createYoltra.

Type parameters

NameTypeDescription
Textends Record<string, unknown>

Parameters

NameTypeDescription
aT
NameTypeDescription
bT

Returns

boolean

Example

example
shallowEqual({ a: 1 }, { a: 1 }); // true
shallowEqual({ a: 1 }, { a: 2 }); // false