react-infinite-calendar
react-infinite-calendar copied to clipboard
Could handle Invalid date inputs better
I experimented with passing invalid dates to InfiniteCalendar and found the following issues that we could improve upon
min={new Date("foo")}
or max={new Date("foo")}
In either of theses cases, the calendar is rendered totally blank.
selected={new Date("foo")}
or selected={{start:new Date("foo"),end:end}}
The calendar renders, but when you try to scroll or select a date, it crashes with an "Invalid offset NaN specified" error in the console.
It would be better to ignore the invalid dates I think.
I stated this: https://github.com/Toodledo/react-infinite-calendar/commit/f2acae1636bb4293a1304a2ca3f1a67c35180f4a
Got it fixed for min/max, but not sure how to properly sanitize "selected" prop.
Hey @offsky,
The sanitization logic for the selected prop is here: https://github.com/clauderic/react-infinite-calendar/blob/master/src/utils/index.js#L135
I think it should probably to default to selected={null} if the input is invalid