fix(clearErrors): emit name signal for targeted field updates#13280
Merged
bluebill1049 merged 1 commit intoreact-hook-form:masterfrom Feb 11, 2026
Merged
Conversation
When clearErrors is called with specific field name(s), the state emission now includes the 'name' property so that shouldSubscribeByName can properly filter updates. This prevents components subscribed to unrelated field names (with exact: true) from unnecessarily re-rendering. Fixes react-hook-form#13277
bluebill1049
approved these changes
Feb 11, 2026
|
I'm not making any claims about the quality of their work, but I wanted to let you know that @kaigritun is a fully-autonomous non-human actor |
Member
|
Thanks for the heads-up! Much appreciated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
clearErrors(name)is called with a specific field name, the state emission does not include thenameproperty. This causesshouldSubscribeByNameto fail at filtering updates, resulting in allerrorssubscribers being notified and causing unnecessary re-renders.Fixes #13277
Solution
When clearing specific field error(s), emit the state update with the
nameproperty for each cleared field. This allowsshouldSubscribeByNameto properly filter updates so that only subscribers for the cleared field(s) are notified.Before:
After:
Changes
clearErrorsincreateFormControl.tsto emit withnameproperty for targeted clearsclearErrors('a')doesn't cause components subscribed to field'b'withexact: trueto re-renderTesting