Uncaught TypeError: Cannot read property 'subscription' of undefined when using FormSpy
See original GitHub issueAre you submitting a bug report or a feature request?
Bug report
What is the current behavior?
When rendering a Form
with a FormSpy
, it becomes impossible to remove the spy from the react hierarchy based on form state, without triggering errors during subscription handling.
In the sandbox example, submitting the form will trigger the form to re-render and only return a string, unmounting the FormSpy
. This will then lead to an error being thrown.
A workaround is to keep rendering the FormSpy
regardless of whether the form has been successfully submitted.
What is the expected behavior?
It should be possible to remove the FormSpy
from the tree without having it conflict with subscription handling.
Sandbox Link
https://codesandbox.io/s/0o6o6mp3ov
What’s your environment?
final-form 4.2.0 react-final-form 3.1.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:10 (5 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'subscription' of undefined
I am using a JS script to implement the Stripe payment provider on a website. The code mainly comes from this tutorial from...
Read more >Final Form Docs – `<FormSpy/>`
import { FormSpy } from 'react-final-form'. A component that subscribes to form state, and injects both form state and the form instance via...
Read more >React TypeError: Cannot read property function of undefined
Solved: React TypeError : Cannot read property function of undefined. 33K views 1 year ago ... Subscribe. 45. I like this. I dislike...
Read more >Hue - app_blacklist minimum apps? - Google Groups
File "/app1/hue/apps/oozie/src/oozie/forms.py", line 340, in <module> ... JS ERROR: {"msg":"Uncaught TypeError: Cannot read property 'TYPES' of undefined" ...
Read more >Fix 'cannot read properties of undefined (reading map)' in JS
The "Uncaught TypeError: Cannot read properties of undefined (reading 'map')" error occurs in JavaScript, whenever you try to use the array ...
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 FreeTop 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
Top GitHub Comments
Published fix in
final-form@4.13.0
.I still have this issue with updated dependencies