Skip to content

Slow array fields performance on 100+ fields #7810

Answered by Moshyfawn
kendoka asked this question in Q&A
Discussion options

You must be logged in to vote

You're subscribing to the form state at the root of your form component

const { errors } = useFormState({
  control
});

and passing it down to your input components. Changing a field updates different form states like dirtyFields state, which would cause your whole form to re-render due to that update subscription you made in the parent component.

To optimize your form, I'd advise you to subscribe to your form state down in your components where you actually need it.
For example, for that errors[fieldName] error message, you can create it's own component and call useFormState inside it, so that only your error component is subscribed and re-rendering on form state change. Additionally, yo…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@kendoka
Comment options

@bluebill1049
Comment options

@bluebill1049
Comment options

@kendoka
Comment options

@oslyvtc
Comment options

Answer selected by kendoka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants