I have a react app. There is a checkbox which disables the datepicker. But I can't select any date when I'm using checkbox to disable it. If I remove checkbox and its function there is no error. Currently, I'm getting:
date.clone is not a function
error.
const dateFormat = "YYYY-MM-DD";
const today = moment();
const [date, setDate] = useState(today);
const [disabled, setdisabled] = useState(false);
const onCheckboxHandle = (e) => {
if (e.target.checked) {
setwarntill(moment("2090-10-10"));
setdisabled(true);
} else {
setwarntill(today);
setdisabled(false);
}
};
<Checkbox onChange={onCheckboxHandle}>Süresiz</Checkbox>
<Form.Item name={["user", "timetill"]} label="Uyarı Bitiş Tarihi">
<ConfigProvider locale={locale}>
<DatePicker
defaultValue={moment()}
format={dateFormat}
onChange={(date,dateString) => setwarntill(dateString)}
value={warntill}
disabled={disabled}
/>
</ConfigProvider>
</Form.Item>