Bug: Conditional rendering of field with promised validate throw error before submit
See original GitHub issueAre you submitting a bug report or a feature request?
A bug report
What is the current behavior?
Since https://github.com/final-form/final-form/pull/369 we can’t use final-form
with conditional rendering coupled with validation function that returns a promise.
The conditions are:
- initial render of the form without field
"buggyField"
- other render with
"buggyField"
"buggyField"
field with a validate function that returns a promise.
We get the following errors and we can’t submit the form:
TypeError: Cannot set property 'validating' of undefined
TypeError: Cannot read property 'active' of undefined
it seems like form.fields[name]
is deleted before function calls.
What is the expected behavior?
Sandbox Link
What’s your environment?
"final-form": "^4.20.2",
"react-final-form": "^6.5.2",
Other information
related to https://github.com/final-form/react-final-form/issues/894
Issue Analytics
- State:
- Created 3 years ago
- Reactions:25
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Bug: Conditional rendering of field with promised validate throw ...
Bug : Conditional rendering of field with promised validate throw error before submit.
Read more >Advanced Usage - React Hook Form
Performant, flexible and extensible forms with easy-to-use validation.
Read more >Can't perform a React state update on an unmounted ...
Before state updates, you now check this variable conditionally: useEffect(() => { let isMounted = true; // note mutable flag ...
Read more >React Suspense: Async rendering in React - LogRocket Blog
See Suspense work its magic with async rendering and the potential impact this feature will have on React applications.
Read more >validate.js
Sometimes it's nice to be able validate field differently depending on the ... If an Error is thrown from an async validator the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think https://github.com/final-form/final-form/pull/369 should be reverted if a fix for this bug doesn’t come quickly. It’s breaking many react-admin apps relying on react-final-form.
I think it’s worth reverting https://github.com/final-form/final-form/pull/409