Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Field Instance exception when unmounting control while being validated even in demo page #371

Closed
codebury opened this issue Feb 14, 2018 · 5 comments

Comments

@codebury
Copy link

Hi,

My code:

@computed ready = false
...
{ this.ready ? <MyFieldset key={item.key} field={item} onAdd={item.onAdd} onDelete={item.onDel} onCancel={() => this.ready = false} /> : null }

Demo steps:

  1. Select "Nested Fields".
  2. Scroll to end and delete all Charlie Chaplin's hobbies.
  3. Click on Add Hobbies and focus the textbox.
  4. Finally, click on delete.

(Sorry, cannot upload images)
Unhandled rejection Error: Validation Error: Invalid Field Instance
at Q (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1346)
at A.e (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1231)
at Q (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1346)
at A.e (https://foxhound87.github.io/mobx-react-form-demo/main.js:15:1231)
at t.validate (https://foxhound87.github.io/mobx-react-form-demo/main.js:40:26827)
at i (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28269)
at T (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28558)
at u (https://foxhound87.github.io/mobx-react-form-demo/main.js:35:28491)

Inside MyFieldset there is a textbox. When I click on cancel button, the control still being on validating process. I suppose that mobx observables are unmounted too late so when the validation process finishes, the control no longer exists.

I think there must be a method that allows the form to be destroyed in the component unmounting process or something similar.

Best regards.

@derekcannon
Copy link

Any chance of getting a fix for this? 🙏🏻

@foxhound87
Copy link
Owner

@derekcannon I still have to figure it out.

@eyrwen
Copy link

eyrwen commented Aug 24, 2021

any progress on this? would be really grateful for a fix

@eyrwen
Copy link

eyrwen commented Aug 24, 2021

For anyone coming here after me:
Setting the options in the Form constructor to be

new Form({...}, {options: { validateOnBlur: false, validateOnChange: true}})

got around the issue for me.

@github-actions
Copy link

🎉 This issue has been resolved in version 5.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants