-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested useFieldArray - watch
values become undefined after moving items
#1038
Comments
watch
values become null after moving itemswatch
values become undefined after moving items
Hey @johncalvinroberts thanks for the kind words ❤️ have you tried watch the entire array field? I will take a close look at your issue soon. |
I think the probably can be solved by just watching the entire field array: The challenge i had with useFieldArray with uncontrolled inputs is value gets set during the render phase instead reading from local state. so i made a fix to make |
Did u try with the above suggestion? |
@bluebill1049 I did try with the above suggestion, and unfortunately it wasn't solving the issue for me...I tried to create a codesandbox reproduction of that bug as well, but couldn't reproduce in codesandbox. In my particular case: I ended up using the old Potentially related: in my particular use case, one of the |
Good point, i should update the docs to reflect that, you can't use custom register with useFieldArray, if you have external component, please use |
Going to close this issue and update accordingly on the website. |
Describe the bug
When using the
move
function fromuseArrayField
in conjunction withwatch
, the watched values return asundefined
after callingmove
.To Reproduce
Steps to reproduce the behavior:
append
3 times to add a total of 4 itemswatch
below the array field, will show the value of all 4 itemsundefined
from thewatch
functionCodesandbox link
https://codesandbox.io/s/react-hook-form-usefieldarray-u1bmc?fontsize=14&hidenavigation=1&theme=dark
Expected behavior
watch
should return the up-to-date values, notundefined
.Additional context
Caveat: this only is reproducible if the values are added to the array, i.e., the array items are appended/added to the array, not supplied by
defaultValues
.P.S. Still really digging this library, big fan :)
The text was updated successfully, but these errors were encountered: