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:
- Create a form with useFieldArray
- append({})
- append({})
- remove(1)
- 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)
https://react-hook-form.com/api#useFieldArray
i think it’s due to this:
register={register()}It’s safer this way, the order version we doing a comparison inside.
follow the temple plz.