I was trying to use singleDatePicer from react-dates,which is a popular date picker library by airbnb, on selecting a date, it throws the error date.format is not a function
, and just breaks, my code sandbox link is -> https://08cg1.csb.app/. Thanks in Advance.
Asked
Active
Viewed 1,409 times
0

Aashiq
- 447
- 1
- 12
- 27
2 Answers
1
singleDatePicker
will accept moment object as date
props so you need to change onDateChange
like below:-
onDateChange={(date) => setDate(date)};

Priyank Kachhela
- 2,517
- 8
- 16
1
onDateChange={(date) => {setDate(date);}}
Here, Don't change the date format and then set the state. Just set the state directly.
If you want to display that selected date somewhere else, there use the moment.
The issue was, once you changed the date format, that format is not supporting as value.

Kirisanth Senthilnathan
- 189
- 1
- 5
-
Hey, Thank you, this is way more explainable – Aashiq May 09 '21 at 15:03