I'm trying to set the default values I'm receiving from the API.
Everything works fine except the nested object values - email
and phone
In general form works well when I'm typing the values and submitting them, but not the other way around.
const { name, description, contact } = fetchedData;
const { email, phone } = contact;
const { reset } = useForm({
mode: "onChange",
defaultValues: {
name,
description,
contact: {
email,
phone,
}
}
})
useEffect(() => {
reset({
name,
description,
contact: {
email,
phone,
}
});
}, [fetchedData]);