-
Hello everyone, maybe someone could advice or explain a strange behaviour on large list, noticed on 100+ lines. Here is CSB link https://codesandbox.io/s/rough-meadow-t9nb7?file=/src/App.js if you press add 100 you will see 100 rows appended, then if you start editing last inputs from length, quantity or width, a noticeable delay is visible like few ms, even if a value is selected from dropdown it also shows ms delay before closing dropdown. Same is pasting 100 lines from spreadsheet, but i commented out for simplicity. Any advice or help is much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
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 To optimize your form, I'd advise you to subscribe to your form state down in your components where you actually need it. |
Beta Was this translation helpful? Give feedback.
You're subscribing to the form state at the root of your form component
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 calluseFormState
inside it, so that only your error component is subscribed and re-rendering on form state change. Additionally, yo…