-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Using async field validator with validateFields crashes (call stack exceeded) #502
Comments
Got into the same issue. Even it's not an async validation, I can see the validate function is called all the time, my browser didn't crash only because the sync ones don't cost too much memory I think. |
Same issue. Here is an rewritten "Synchronous Field-Level Validation" example with this bug: The only workaround I found is to remove all validateFields attributes. |
Found a better workaround. react-final-form/src/useField.js Line 102 in d4f6ca8
Using an inline validateFields={[]} actually creates a new array on each render, causing the effect to fire every time.
Declaring something like const emptyArr = []; Outside of the component (or as a class property or whatever, just make sure it stays the same actual object) and passing that to validateFields works fine. |
Thanks guys. Great reporting. |
Published fix in |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
Crash (call stack exceeded) when using an async validator and validateFields={[]} on any version of react-final-form above >=5.x
What is the expected behavior?
It should not get stuck 😄
Sandbox Link
https://codesandbox.io/s/tender-jang-o2grh
WARNING: The tab gets stuck for a bit when loading the sandbox, this is the issue so that's intentional.
What's your environment?
Latest versions, see sandbox.
Other information
Works fine on 4.1
The text was updated successfully, but these errors were encountered: