You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you trigger validation on any single field, there doesn't seem to be any way to isolate the re-render to only the component that is reading the Error for that field. Any components that read the error state will re-render, even if they are ostensibly only reading the state for their own field as well.
I would think that a component that has the following code:
Would only be subscribed to changes in the error for someFieldName and not for all error updates, but in fact this will re-render when any field is validated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If you trigger validation on any single field, there doesn't seem to be any way to isolate the re-render to only the component that is reading the Error for that field. Any components that read the error state will re-render, even if they are ostensibly only reading the state for their own field as well.
I would think that a component that has the following code:
Would only be subscribed to changes in the error for
someFieldName
and not for all error updates, but in fact this will re-render when any field is validated.Example CSB:
https://codesandbox.io/p/sandbox/react-hook-form-v7-ts-triggervalidation-forked-2dy577
In the example, if you trigger validation on the First Name field, both inputs will re-render and the render count will update.
Beta Was this translation helpful? Give feedback.
All reactions