Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async validation re-renders all fields #74

Open
bostrom opened this issue Nov 8, 2021 · 1 comment
Open

Async validation re-renders all fields #74

bostrom opened this issue Nov 8, 2021 · 1 comment

Comments

@bostrom
Copy link

bostrom commented Nov 8, 2021

Not sure if this is a Final Form Arrays or a Final Form or Yup issue, but posting it here for initial guidance.

Seems that when I have a form with a FieldArray and async validation (Yup), all empty fields in the array re-renders on each keypress in any other field (even outside the array), even if all subscriptions are disabled.

When comparing the meta information for the rendered component, it seems that meta.errors, meta.invalid and meta.valid changes briefly when typing. Given the field is invalid, the field will briefly turn valid and then invalid again, making it re-render even though nothing actually changed.

Changing the validation to sync resolves the issue.

The following sandbox showcases the issue, and includes a sync validator for comparison.

https://codesandbox.io/s/react-final-form-field-arrays-w-async-validation-nlr1i?file=/index.js

What's your environment?

🏁 Final Form Arrays version 3.0.2
🏁 Final Form version 4.20.2

@jaryway
Copy link

jaryway commented Dec 29, 2021

May be the same problem!

you need to add validateFields={[]} to all fields in FieldArray and comany field.
although,add/remove array item making re-render all fields
final-form/react-final-form-arrays#168

https://codesandbox.io/s/new-waterfall-vhlw2?file=/index.js

vvvv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants