wojtekmaj / react-calendar

Ultimate calendar for your React app.
https://projects.wojtekmaj.pl/react-calendar
MIT License
3.52k stars 509 forks source link

Method get Intl.DateTimeFormat.prototype.format called on incompatible receiver undefined #901

Closed samuelloranger closed 11 months ago

samuelloranger commented 11 months ago

Before you start - checklist

Description

When trying to update packages in my app, I updated react-calendar from 3.6.0 to 4.6.0.

Runned into this issue when running the app, when react-calendar is loaded, I get this error: (Printing multiple times in theh console)

date-time-format-timezone-complete-min.js:1 Uncaught TypeError: Method get Intl.DateTimeFormat.prototype.format called on incompatible receiver undefined at get format () at d (date-time-format-timezone-complete-min.js:1:5272) at d (date-time-format-timezone-complete-min.js:1:5198) at value (date-time-format-timezone-complete-min.js:1:7245) at formatter (dateFormatter.js:13:1) at eval (dateFormatter.js:31:1) at Day (Day.js:47:1) at renderWithHooks (react-dom.development.js:16305:1) at mountIndeterminateComponent (react-dom.development.js:20074:1) at beginWork (react-dom.development.js:21587:1)

I get the same error for Day.js, Weekdays.js, and Navigation.js

Steps to reproduce

Just adding the calendar anywhere in my app crashes the page.

Expected behavior

No crash

Actual behavior

App crashing

Additional information

Console: https://imgur.com/a/hF5WNMC

Environment

wojtekmaj commented 11 months ago

date-time-format-timezone-complete-min.js

You're using an Intl polyfill which overrides native Intl method, causing the error.

BTW, you likely don't need it.

samuelloranger commented 11 months ago

Wow thanks for the quick response and thanks a lot for the help. Did not realised these polyfills were still used. <3