So i wanted to use the react date picker with react hook forms. I referred this question and implemented this code:
<Controller
control={control}
name="deadline"
render={({ field }) => (
<DatePicker
onChange={(date) => onChange(date)}
value={value}
format="dd-MM-y"
clearIcon={<AiOutlineClose />}
calendarIcon={<AiOutlineCalendar />}
required
monthPlaceholder="mm"
dayPlaceholder="dd"
yearPlaceholder="yyyy"
style={{ color: "whitesmoke" }}
minDate={new Date()}
/>
)}
/>
const [value, onChange] = useState(new Date());
The problem I am facing is that, on submitting the form, i am not getting any error, but the value of the date field "deadline" is remaining undefined. The default value of the date picker is Current date. Is there something im doing wrong here ?