[useFieldArray] How to properly remove properties added to a fieldArray #12334
Answered
by
BrendanC23
tatsuya-asami
asked this question in
Q&A
-
What is occurring
screen shotinput valuesafter click remove by remove of uid 2My questions
sandobxhttps://codesandbox.io/p/github/tatsuya-asami/react-hook-form-sync-field-array/main react 18.3.1 |
Beta Was this translation helpful? Give feedback.
Answered by
BrendanC23
Oct 14, 2024
Replies: 1 comment 3 replies
-
Before anything is deleted, you have:
After deleting the item at index 1, you have:
When you remove an item, you aren't clearing the Try this code: <button type="button" onClick={() => {
setEditingUid(null);
remove(index);
}}> |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
tatsuya-asami
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before anything is deleted, you have:
After deleting the item at index 1, you have:
When you remove an item, you aren't clearing the
editingUid
. This means that the description's input is still associated with index 1, which is now "user 3".Try this code: