I try to do it like so, but it does nothing...
import {useForm, FormContext} from 'react-hook-form';
const formMethods = useForm({mode: 'onSubmit'});
const {triggerValidation} = formMethods;
triggerValidation('myFieldName');
return (
<FormContext {...formMethods}>
//here are my form fields, one of which has the key of 'myFieldName'
</FormContext>
);
you've to use trigger method: https://react-hook-form.com/api/useform/trigger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With