react-hook-form: V7 Major Bug - useFieldArray and reset() crash application
Describe the bug
If a field array has an empty array for it’s default value and reset is called, then react-hook-form will throw an unhandled error and crash the application.
To Reproduce Steps to reproduce the behavior:
- Click reset
- Optionally append some values
Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-controller-template-forked-ydf5r?file=/src/index.js
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
Commits related to this issue
- fix #4111 issue with reset field array as undefined fix #4108 setValue issue with controller not updating — committed to react-hook-form/react-hook-form by bluebill1049 3 years ago
- fix issues: 4111 & 4108 (#4113) * fix #4111 issue with reset field array as undefined fix #4108 setValue issue with controller not updating * fix code analyze — committed to react-hook-form/react-hook-form by bluebill1049 3 years ago
- 7️⃣ V7 (#3741) * use useFormState with useController internally and new isValidating state(#3778) * use useFormState with useController internally * remove console.log * V7 Register (WIP) (#... — committed to react-hook-form/react-hook-form by bluebill1049 3 years ago
My bad. I thought RC is newer than beta so I went with that. Oh well. Ok, so it looks like everything is working fine now! Thanks so much for everyone’s help on this. Really appreciate it.
@wdfinch get the latest beta of
resolver, @jorisre did a lot of amazing stuff on that, and much smaller bundle size.not the
rc,beta(It was a mistaken release with rc)Thanks so much! I now have a breaking issue related to @hookform/resolvers. It appears that the resolvers rely on an export called “transformToNestObject”. After upgrading, I’m getting an error because those files can’t find this export. Was this item removed or modified in the patch just now?
I would show a sandbox, but I can’t get this error in the sandbox, possibly because it all happens inside code that hasn’t been run yet/is outside the project scope.
This is specially the line that is giving me trouble:
import { appendErrors, transformToNestObject, } from 'react-hook-form';