Skip to content
Discussion options

You must be logged in to vote

You're mixing the concept of controlled vs uncontrolled input by providing the value prop to a "registered" input element.

Notice that the change event's not firing when the field array is re-rendered after the swap operation, so the new index value is not updated in the RHF state.

You want to manually update the field

  • either by calling setValue on the index change
  • or convert your hidden input into a controlled input and pass the index into it's onChange handler

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wojtekow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants