我正在使用 带钩子的REACT JS
import useForm from "react-hook-form";
const { handleSubmit, register, errors } = useForm();
<Form className="sign-up-form" onSubmit={handleSubmit(onSubmit)}> // form start
<Col md={12} mb={3}>
<label htmlFor="visatype">Visa Type</label>
<div className="form-group">
<select className="custom-select form-control"
name="visa_type_id"
value={ VisaTypeId }
ref={register({ required: true })}
onChange={e => setVisaTypeId(e.target.value)}
required>
<option value="">
Select...{" "}
</option>
{DynamicOptions(visaTypes)}
</select>
<div className="invalid-feedback">
{errors.visa_type_id && 'Visa Type is required.'}
</div>
</div>
</Col>
我正在使用此ref={register({ required: true })}
进行验证,我是在未选择“第一次选择错误时选择值”中选择值