-
Goal: Problem: I don't know how to solve it. Info: Stackblitz: Thank you!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
RHF initializes your form with the provided default values only ones when the There're different approach you can choose to provide the const { resetField } = useForm()
useEffect(() => {
if (category) {
resetField("favShow", { defaultValue: category })
}
}, [resetField, category]) Check out this working codesandbox |
Beta Was this translation helpful? Give feedback.
RHF initializes your form with the provided default values only ones when the
useForm
hook is first called with the provideddefaultValues
.There're different approach you can choose to provide the
async
default values to your form. In your case, since there's only oneasync
field value, you can utilize theresetField
form method to "update" your default field value once you get it.Check out this working codesandbox