Nested useFieldArray
validation validates deleted indices.
#10260
Unanswered
DarryQueen
asked this question in
Q&A
Replies: 2 comments 2 replies
-
please use the above code to bug your issue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Please read carefully the documentation https://react-hook-form.com/api/usefieldarray/
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Version Number
7.43.9
Codesandbox/Expo snack
https://codesandbox.io/s/modest-pond-l24ue7
Steps to reproduce
topLevel1
andtopLevel2
).nested1
).`array.${number}.nestedArray`
) throws an error, saying the array value is undefined.Expected behaviour
The validation should succeed (or at least not error).
I believe this is because additional indices are not being accounted for. There are originally 2 array values; I delete one so there should only be 1. The nested validation (
`array.${index}.nestedArray`
) is validating with field names`array.${0}.nestedArray`
and`array.${1}.nestedArray`
, and the latter cannot find a value (because it was deleted).What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions