react-hook-form: remove from useFieldArray doesn't work correctly

Please consider asking the question at our spectrum channel.

https://spectrum.chat/react-hook-form

Describe the question?

To Reproduce Steps to reproduce the behavior:

  1. use useFieldArray
  2. Append new members
  3. removeing doesn’t work as expected, deletes other members than the one needed

Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-usefieldarray-zs0lp

Additional context I couldn’t replicate my issue as I experienced it, but I also had an issue where removeing a member would completely wipe my array

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 26 (12 by maintainers)

Most upvoted comments

@bluebill1049 whats up~ I think I love your library? Haven’t fully decided yet, but its def fun.

v. 6.8.0

I’m having the same issue. heres a CSB - https://codesandbox.io/s/react-hook-form-field-array-append-remove-df816?file=/src/index.js

append some fields and assign different values and see the remove, removing random ones. Any ideas?

Screen Shot 2020-09-11 at 3 25 28 pm

make sure you go through the doc with the important note, i think you are missing the id

@bluebill1049 Wow, that was it. Must’ve missed it. Thanks for the thorough documentation ❤️.

Thanks for quick revert. the field array name was a typo. Somehow it works in CDB but not local. I follow your example more closely and get back if I still face issues. Do you think name: "experiment.fields" may be the cause of issue? The object has more depth in my case.

maybe try to follow the CSB example, see if you can achieve similarly?

Thank you for being so responsive!

I have a form for creating an array of floors like so: image

With each floor having fields like so: image

Once I try to remove one of the floors I’ve added, I get my whole array wiped like so: before: image

after: image