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.

Uncaught TypeError: Cannot read property 'subscription' of undefined when using FormSpy

See original GitHub issue

Are 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
erikrascommented, May 16, 2019

Published fix in final-form@4.13.0.

2reactions
mschipperheyncommented, Dec 31, 2018

I still have this issue with updated dependencies

Uncaught (in promise) TypeError: Cannot read property 'subscription' of undefined
    at final-form.es.js:382
    at Array.forEach (<anonymous>)
    at notify (final-form.es.js:380)
    at notifyFormListeners (final-form.es.js:798)
    at complete (final-form.es.js:1132)
Read more comments on GitHub >

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

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