Bug report
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.
It should be possible to remove the FormSpy from the tree without having it conflict with subscription handling.
https://codesandbox.io/s/0o6o6mp3ov
final-form 4.2.0
react-final-form 3.1.0
Is there any news regarding this bug?
I'm trying to reproduce it.
reproduced, let me debug it.
Updating the FF and RFF deps in that code sandbox fixes the problem. 🤷♂️
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)
Just found the same error (version 4.12.0)
final-form.es.js:407 Uncaught (in promise) TypeError: Cannot read property 'subscription' of undefined
at final-form.es.js:407
at Array.forEach (<anonymous>)
at notify (final-form.es.js:405)
at notifyFormListeners (final-form.es.js:827)
at complete (final-form.es.js:1182)
For what it's worth, it is also happening with final-form 4.11.1 and react-final-form 4.0.2.
I am unsure what are the conditions to replicate it. I will post more information when I identify what conditions trigger this error.
Published fix in [email protected].
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.
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.
Most helpful comment
Published fix in
[email protected].