Following the documentation, I'm trying to implement example #15
However I get:
./src/components/Calendar.js
Line 32: 'addDays' is not defined no-undef
Custom date format also doesn't work
I've installed date-fns manually and referenced it in my component. Still doesn't work.
Is the documentation not complete? Am I missing an import? From the source I see date_utils being referenced when going through the code, which has date-fns imported, but doesn't seem to work at all
Help would be appreciated
Don't know if it's og any help. But I imported the addDays directly and works like a charm!
Like so:
import { addDays } from 'date-fns';
i found a better way.
use the below code
import { addDays } from 'material-ui/DatePicker/dateUtils'
For all the functions used in props, you import them from 'date-fns'.
import { addDays } from "date-fns";
For example, to set a max date of 18 years ago (to not allowed minor age for example), you would use it like this:
import { subYears } from "date-fns";
<DatePicker
...
maxDate={subYears(new Date(), 18)}
/>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Don't know if it's og any help. But I imported the
addDaysdirectly and works like a charm!Like so: