react-hook-form: TypeError property 0 is non-configurable and can't be deleted - Firefox
Describe the bug
When using a file type input in Firefox and unmounting a component, the unsetObject function (src/utils/unset.ts, line 26) tries to delete an element of FileList Array. In Firefox, this object is non-configurable, throwing an error.
To Reproduce Steps to reproduce the behavior:
- Using Firefox, create a form with an input file and register it in react-hook-form
- Add a file to it
- Unmount the component
- See error
Codesandbox link Will add later
Expected behavior No error.
Screenshots
Desktop (please complete the following information):
- OS: Windows 10, macOS Catalina
- Firefox
- Version 72.0.2 (macOS)
Smartphone (please complete the following information):
- Not tested
Additional context
In my app, the input is in a child Materials-UI modal. The input, however, is a native HTML.
After clicking submit, handleSubmit execute a function that updates the parent state, closing the modal. Then, the error occurs.
I couldn’t use react-hook-form for this input type, however, I still used it with the other form inputs. As a workaround, I set an onChange in the file input that sets a state with the file list. Then, at submitting, before sending the form data collected by react-hook-form to the API, I injected the state data.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 17 (11 by maintainers)
Commits related to this issue
- fix #932 issue around delete file list object in FF — committed to react-hook-form/react-hook-form by bluebill1049 4 years ago
Working Great! Thanks!
patched: https://codesandbox.io/s/epic-microservice-o6i7d if you can verify, i will merge the fix.
yea i did, it’s only to do with nested inputs. I will patch that soon. (only in FF as well)