1import {useForm} from 'react-hook-form';
2const {register,handleSubmit,formState: { errors }} = useForm();
3<form onSubmit={handleSubmit(onSubmit)}>
4<input name='to' placeholder="To" type="text" {...register("to",{ required: true })}/>
5{errors.to && <p className="sendMail_error">To is required</p>}
6 </form>