react-native-ui-datepicker
react-native-ui-datepicker copied to clipboard
Runtime errors: calendar(...).locale is not a function / calendar(...).format is not a function
Currently getting some runtime errors in my react-native-web project. Using [email protected] with [email protected], [email protected] and react/[email protected].
Logs
Uncaught runtime errors:
×
ERROR
dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
at MonthButton (http://localhost:3000/static/js/bundle.js:331541:105)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:256925:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:259805:24)
at updateSimpleMemoComponent (http://localhost:3000/static/js/bundle.js:259667:14)
at updateMemoComponent (http://localhost:3000/static/js/bundle.js:259540:18)
at beginWork (http://localhost:3000/static/js/bundle.js:261570:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:246521:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:246565:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:246622:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:266486:11)
ERROR
dayjs__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).format is not a function
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).format is not a function
at YearButton (http://localhost:3000/static/js/bundle.js:331940:102)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:256925:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:259805:24)
at updateSimpleMemoComponent (http://localhost:3000/static/js/bundle.js:259667:14)
at updateMemoComponent (http://localhost:3000/static/js/bundle.js:259540:18)
at beginWork (http://localhost:3000/static/js/bundle.js:261570:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:246521:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:246565:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:246622:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:266486:11)
ERROR
dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
at MonthButton (http://localhost:3000/static/js/bundle.js:331541:105)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:256925:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:259805:24)
at updateSimpleMemoComponent (http://localhost:3000/static/js/bundle.js:259667:14)
at updateMemoComponent (http://localhost:3000/static/js/bundle.js:259540:18)
at beginWork (http://localhost:3000/static/js/bundle.js:261570:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:246521:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:246565:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:246622:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:266486:11)
ERROR
dayjs__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).format is not a function
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_3___default(...)(...).calendar(...).format is not a function
at YearButton (http://localhost:3000/static/js/bundle.js:331940:102)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:256925:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:259805:24)
at updateSimpleMemoComponent (http://localhost:3000/static/js/bundle.js:259667:14)
at updateMemoComponent (http://localhost:3000/static/js/bundle.js:259540:18)
at beginWork (http://localhost:3000/static/js/bundle.js:261570:20)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:246521:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:246565:20)
at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:246622:35)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:266486:11)
ERROR
dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
TypeError: dayjs__WEBPACK_IMPORTED_MODULE_1___default(...)(...).calendar(...).locale is not a function
at MonthButton (http://localhost:3000/static/js/bundle.js:331541:105)
at renderWithHooks (http://localhost:3000/static/js/bundle.js:256925:22)
at updateFunctionComponent (http://localhost:3000/static/js/bundle.js:259805:24)
at updateSimpleMemoComponent (http://localhost:3000/static/js/bundle.js:259667:14)
at updateMemoComponent (http://localhost:3000/static/js/bundle.js:259540:18)
at beginWork (http://localhost:3000/static/js/bundle.js:261570:20)
at beginWork$1 (http://localhost:3000/static/js/bundle.js:266464:18)
at performUnitOfWork (http://localhost:3000/static/js/bundle.js:265734:16)
at workLoopSync (http://localhost:3000/static/js/bundle.js:265657:9)
at renderRootSync (http://localhost:3000/static/js/bundle.js:265630:11)
My project compiles fine but if I look at the stated files, TS linting tells me that Property 'calendar' does not exist on type 'Dayjs'. If I import calendar from 'dayjs/plugin/calendar' and dayjs.extend(calendar) that TS error disappears, however, the return of that method is a string which doesn't allow chaining with .locale() or .format(). If I patch those files by removing the .calendar(calendar) parts from the /src/components/header/month-button.tsx and /src/components/header/year-button.tsx files, the runtime errors disappear.
Downgrading to [email protected] also resolves the issue.