Field State updates not working without console.log #12587
Replies: 1 comment
|
I don't think the console.info itself is causing the field state to update. It is more likely exposing a subscription/rendering issue.
For example: const { errors, dirtyFields, touchedFields, validatingFields } = useFormState({ const error = errors[formField.name]; This makes the component explicitly subscribe to the relevant form state instead of relying on Another option is to pass the formState into const { formState, getFieldState } = useFormContext(); const { invalid, isDirty, error, isTouched } = So I would treat the |
Uh oh!
There was an error while loading. Please reload this page.
I'm using React Hook Form (v7) with a custom
useFormFieldhook that usesgetFieldState. I've noticed that real-time field state updates (like validation states) only work when I include aconsole.infostatement in the hook. Without it, the component doesn't return the correct value for the field states.Code that doesn't work
Why does field state updating depend on console.info, and what's the proper way to handle this? Is this a known issue with React Hook Form's subscription system? I'm really confused. I can't wrap my head around this.
All reactions