react-hook-form: useFieldArray: TypeError: data.slice is not a function

Describe the bug All multiple elements (useFieldArray) and remove them, the first work, but the second click leads to the following error message:

TypeError: data.slice is not a function
removeAt
node_modules/react-hook-form/dist/react-hook-form.es.js:1438

To Reproduce Steps to reproduce the behavior:

  1. Create a form with useFieldArray
  2. append({})
  3. append({})
  4. remove(1)
  5. remove(0)

https://codesandbox.io/s/react-hook-form-usefieldarray-1qmyt https://github.com/chubbyphp/petstore-react/blob/tailwind-css/src/Component/Form/PetForm.tsx

Expected behavior Element gets removed without any issue.

Desktop (please complete the following information):

  • OS Ubuntu 19.10
  • Browser Firefox
  • Version 74

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

https://react-hook-form.com/api#useFieldArray

i think it’s due to this:

register={register()}

Screen Shot 2020-04-06 at 3 42 40 pm

It’s safer this way, the order version we doing a comparison inside.

Screen Shot 2020-04-06 at 7 32 22 am

follow the temple plz.