Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  33] [ 6]  / answers: 1 / hits: 42778  / 4 Years ago, sun, october 25, 2020, 12:00:00

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>

More From » reactjs

 Answers
13

parsing the date with the help of moment works for me
moment(myDate)


[#50584] Tuesday, October 6, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryderalfonsos

Total Points: 655
Total Questions: 88
Total Answers: 91

Location: Nauru
Member since Thu, Feb 2, 2023
1 Year ago
ryderalfonsos questions
Mon, Sep 9, 19, 00:00, 5 Years ago
Wed, Feb 13, 19, 00:00, 5 Years ago
Tue, Feb 12, 19, 00:00, 5 Years ago
Fri, Dec 28, 18, 00:00, 6 Years ago
;