react hook form setError code example
Example: how to use error in react hook form
import {useForm} from 'react-hook-form';
const {register,handleSubmit,formState: { errors }} = useForm();
<form onSubmit={handleSubmit(onSubmit)}>
<input name='to' placeholder="To" type="text" {...register("to",{ required: true })}/>
{errors.to && <p className="sendMail_error">To is required</p>}
</form>