The comparison option has three names: compare in usePrevious, equalityFn in useControlledState, and areValuesEqual in usePreservedReference. All three have the same type, (a, b) => boolean.
- Rename the parameter to
equalityFn in usePrevious and usePreservedReference. Both are positional, so only types and docs change.
- Change the default in
usePrevious from === to Object.is, which useControlledState and React already use. Only NaN and -0 behave differently.
- Keep the deep comparison default in
usePreservedReference, because keeping the reference of deeply equal values is what the hook is for.
Update types, docs, and tests.
The comparison option has three names:
compareinusePrevious,equalityFninuseControlledState, andareValuesEqualinusePreservedReference. All three have the same type,(a, b) => boolean.equalityFninusePreviousandusePreservedReference. Both are positional, so only types and docs change.usePreviousfrom===toObject.is, whichuseControlledStateand React already use. OnlyNaNand-0behave differently.usePreservedReference, because keeping the reference of deeply equal values is what the hook is for.Update types, docs, and tests.