Skip to content

Fixed isEqual register initalization#1033

Merged
erikras merged 1 commit intofinal-form:mainfrom
mjchang:bug/is-equal-initialization
Feb 10, 2026
Merged

Fixed isEqual register initalization#1033
erikras merged 1 commit intofinal-form:mainfrom
mjchang:bug/is-equal-initialization

Conversation

@mjchang
Copy link
Contributor

@mjchang mjchang commented May 20, 2023

Remove the unnecessary isEqual function definition. This was necessary because #1032 is fixed by updating the field isEqual every time registerField is called. This fix relies on the fact that isEqual is only defined when necessary which this change does.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed field state comparison logic to ensure consistent behavior when equality checks are configured for form fields.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0eb8e6f:

Sandbox Source
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

The useField.ts file has been modified to pass the isEqual option directly from the config without a fallback. Previously, if isEqual was not provided, it would default to defaultIsEqual; now it passes the value as-is to form.registerField.

Changes

Cohort / File(s) Summary
Field Equality Configuration
src/useField.ts
Removed fallback to defaultIsEqual for the isEqual option in field registration, now passing configRef.current.isEqual directly without runtime default behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A little tweak, so lean and clean,
No fallback shield, just config seen,
Direct equality takes the stage,
One line rewrote this tiny page,
Simplicity hops through the code!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fixed isEqual register initalization' directly relates to the main change, which modifies how the isEqual option is initialized during field registration in useField.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/useField.ts (1)

30-30: 🧹 Nitpick | 🔵 Trivial

Remove unused defaultIsEqual constant.

defaultIsEqual is no longer referenced after the change on line 93 where isEqual is now passed directly from configRef.current.isEqual.

♻️ Proposed fix
-const defaultIsEqual = (a: any, b: any): boolean => a === b;
-

@erikras erikras merged commit f25a24e into final-form:main Feb 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants