question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Conditional rendering of field with promised validate throw error before submit

See original GitHub issue

Are 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

Sandbox

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:closed
  • Created 3 years ago
  • Reactions:25
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
fzaninottocommented, Mar 18, 2021

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.

6reactions
gbakernetcommented, Mar 25, 2021
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found