fields of useFieldArray cannot read data #11138
Replies: 1 comment
-
I found out the cause, not the issue of react-hook-form |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am using useFieldArray to control my forms in 2 modals, one is running normally, but the other one is not, the fields of useFieldArry cannot read data that I passed into useForm / defaultValues, and I don't know what the cause is.
here's my repo of the one running normally: modal-1 line-68
` const {
control,
formState: { errors },
getValues,
register,
reset,
setValue,
trigger,
watch,
} = useForm({
resolver: zodResolver(orderFormSchema),
defaultValues: order,
});
and here's the one can not read default values: modal-2 line-68
`
const {
control,
formState: { errors },
getValues,
register,
reset,
setValue,
trigger,
watch,
} = useForm({
resolver: zodResolver(orderPaymentSchema),
defaultValues: { payments: order.payments }, // the order.payments is not an empty array
});
`
Beta Was this translation helpful? Give feedback.
All reactions