Replies: 8 comments 3 replies
-
Hi @samislam, |
Beta Was this translation helpful? Give feedback.
-
Can confirm - same issue here |
Beta Was this translation helpful? Give feedback.
-
I also experience this issue. I'm on version |
Beta Was this translation helpful? Give feedback.
-
Yes, I am facing same issue. I need to show form errors in edit mode. I tried calling trigger in onMount using useEffect. I can see errors when page is loaded, however, error messages does not go away even after valid values are entered in the input. |
Beta Was this translation helpful? Give feedback.
-
Here's an implementation utilizing the trigger function |
Beta Was this translation helpful? Give feedback.
-
Did any one found solution? |
Beta Was this translation helpful? Give feedback.
-
IssueWhen using
SolutionTo address this, the following steps are implemented:
Code Implementation
Explanation
Note: getFieldState is available in the return value of useForm() and introduced in version (v7.25.0) of react-hook-form |
Beta Was this translation helpful? Give feedback.
-
Same issue here. I'm on const handleConfirm = async () => {
const isValid = await trigger();
setOpenConfirmationDialog(isValid);
};
const onSubmit = handleSubmit((data) => {
mutation.mutate(data);
});
return (
<form onSubmit={handleConfirm}>
...
{openConfirmationDialog && <ConfirmationDialog onSubmit={onSubmit} />
</form>
) |
Beta Was this translation helpful? Give feedback.
-
I have the following code:
If I write "h" in the input field, and then I click on the "Submit!" button, of course I see a validation error, and the error message gets print on the screen:
This is good. however, the normal behavior of react-hook-form now is I have to click on the "Submit!" button again to get rid of the red error message.
Is using
trigger()
makes everything from now on manual? is that documented anywhere?I want the normal react-hook-form behavior to happen, so that when I write inside the input field, the error goes away as I type correctly.
Here's a preview in stack bilitz (if you're using brave browser, turn off the shields).
Beta Was this translation helpful? Give feedback.
All reactions