react-final-form icon indicating copy to clipboard operation
react-final-form copied to clipboard

Async validation triggers field render twice

Open vladshcherbin opened this issue 7 years ago • 5 comments

Are you submitting a bug report or a feature request?

Not sure if this is a bug or a current feature 🤔

What is the current behavior?

When using async form validation (before submit), it triggers field render twice. First one with error set to none and then with actual error. This happens on every keypress.

What is the expected behavior?

I'd like to make it work as a sync one when there is only one render on keypress and no error state pop before/after validation.

Sandbox Link

https://codesandbox.io/s/n9kn940k84

In this example, there are both validateAsync and validateSync for test, open console to see the difference.

What's your environment?

React Final Form version 3.6.5 Final Form version 4.9.1

@erikras maybe you have an idea what to do with this 🙏

vladshcherbin avatar Aug 20 '18 09:08 vladshcherbin

I see same behaviour

seeden avatar Dec 19 '18 15:12 seeden

I have same problem. On first render, my Wizard Form trigger form validation every time. My form validation is async function and every field trigger validation on render the form. If i have 20 fields, this breaks my page.

Why i can't stop validation on first render? And this flag validateOnBlur has no effect. Whatever i put true or false it's same, on load my page my Wizard trigger nth times the Form validation and Validation trigger render function again.

xelaz avatar Mar 14 '19 19:03 xelaz

This bug still encounter :(

React Final Form version 6.0.0 Final Form version 4.13.0

huczk avatar Feb 21 '21 11:02 huczk

Still an issue today, mixing synchronous and asynchronous as with react-redux is a pain with final-form :'(

I have a visual glitch where the synchronous error disappears while the promise is being resolved

bertho-zero avatar Feb 22 '22 17:02 bertho-zero

the current behavior is correct. one for value change,one for error message change!

jaryway avatar May 31 '23 02:05 jaryway