rehookify / datepicker

The ultimate tiny tool for creating date and range pickers in your React applications.

Home Page:https://rehookify.com/datepicker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error resetting selected dates in "range" mode with a single date selected

relsunkaev opened this issue · comments

If the selectedDates state is reset to an empty array when it's in mode: "range" and one of the dates is selected, the following error is thrown:

index.esm.mjs?93b8:7 Uncaught TypeError: Cannot read properties of undefined (reading 'getDate')
    at getDateParts (index.esm.mjs?93b8:7:1)
    at getCleanDate (index.esm.mjs?93b8:17:1)
    at getDateRangeState (index.esm.mjs?93b8:189:1)
    at createCalendar (index.esm.mjs?93b8:216:1)
    at eval (index.esm.mjs?93b8:228:90)
    at Array.map (<anonymous>)
    at createCalendars (index.esm.mjs?93b8:228:90)
    at useCalendars (index.esm.mjs?93b8:233:1)
    at useDatePicker (index.esm.mjs?93b8:575:1)
    at DatePicker (DatePicker.tsx?b640:31:20)
    at renderWithHooks (react-dom.development.js?3c4a:16305:1)
    at updateFunctionComponent (react-dom.development.js?3c4a:19588:1)
    at beginWork (react-dom.development.js?3c4a:21601:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js?3c4a:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?3c4a:4213:1)
    at invokeGuardedCallback (react-dom.development.js?3c4a:4277:1)
    at beginWork$1 (react-dom.development.js?3c4a:27451:1)
    at performUnitOfWork (react-dom.development.js?3c4a:26557:1)
    at workLoopSync (react-dom.development.js?3c4a:26466:1)
    at renderRootSync (react-dom.development.js?3c4a:26434:1)
    at performSyncWorkOnRoot (react-dom.development.js?3c4a:26085:1)
    at flushSyncCallbacks (react-dom.development.js?3c4a:12042:1)
    at eval (react-dom.development.js?3c4a:25651:1)

@relsunkaev , hi, thanks for reaching out with the issue.
I will try to take a look and fix later today

@relsunkaev, please to v4.1.5
If this fix doesn't resolve this problem, please LMK.
Thanks, once again for reporting this bug 🙏

Thanks for such a quick response! I'll check it out today