当我单击提交按钮时。它没有显示必填错误,因为它是必填字段。这是我的代码。我已经注册了 required 并且还尝试使用规则但仍然没有得到必需的验证
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<Controller
as={
<KeyboardDatePicker
autoOk
disableToolbar
variant="inline"
format="MM/dd/yyyy"
id={"appointmentDate"}
inputVariant="outlined"
inputRef={register({ required: true })}
label={"Appointment Date"}
required={true}
helperText={errors["appointmentDate"] && "Required..!!"}
error={errors["appointmentDate"] ? true : false}
KeyboardButtonProps={{
"aria-label": "change date"
}}
/>
}
rules={{ validate: value => value === null || "Required ..!!" }}
name={"appointmentDate"}
control={control}
/>
</MuiPickersUtilsProvider>
https://codesandbox.io/s/mui-autocomplete-with-react-hook-form-1p3x5