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:

  1. Click reset
  2. 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

Most upvoted comments

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';