Skip to content

Rename equality options to equalityFn #540

Closed

Description

@hyesungoh

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.

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. mnxmnz commented on Oct 6, 2026

    @mnxmnz
    Member

    Landed in v1-base via #544 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions