'Using the react-date-picker with react hook forms
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 ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
