🚄 perf: separate control context to prevent unnecessary rerenders#13234
Merged
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom Jan 5, 2026
Merged
Conversation
Introduce HookFormControlContext for internal hooks (useController, useFieldArray, useFormState, useWatch) to avoid rerenders when only control is needed.
4d29f85 to
2ac2426
Compare
bluebill1049
reviewed
Jan 4, 2026
Member
bluebill1049
left a comment
There was a problem hiding this comment.
could u increase the bundle size config at the package.json? nice work
bluebill1049
approved these changes
Jan 5, 2026
|
Quick question about this change. Previously I was passing in an additional function to the which I could get back from useFormContext(). This change breaks that. Would there be a way to still allow this? |
Contributor
Author
Could you consider using one more custom context for your function? You can create your own context as a one more wrapper around forms. |
1 task
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.
Introduce HookFormControlContext for internal hooks (useController, useFieldArray, useFormState, useWatch) to avoid rerenders when only control is needed.
Currently, even if the context were memoized, there would still be an unnecessary cause for rerenders in these hooks — formState — even though it's not actually used internally. This PR completely breaks the dependency on formState and makes the hooks isolated from the shared context.
I intentionally did not export the new hook in the public API, as I don't think there's a reason to expand it.
Partial work for #13233