New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update from 2.20.2 to 2.20.3 breaks my application with "de" locale #2474
Comments
I deleted my previous reply because I thought the date-fns dependency in codesandbox was wrong, but I think it was fine after all. Give this a shot. Like I previously mentioned, prob mixing import { Calendar, dateFnsLocalizer } from 'react-big-calendar'
import {format, parse, startOfWeek, getDay} from 'date-fns'
import {enUS, de} from 'date-fns/locale'
const locales = {
'en-US': enUS,
'de': de,
};
const localizer = dateFnsLocalizer({
format,
parse,
startOfWeek,
getDay,
locales,
})
const MyCalendar = props => (
<div>
<Calendar
style={{ height: 500, width: 500, margin: 'auto', }}
localizer={localizer}
culture='de'
startAccessor="start"
endAccessor="end"
events={[]}
/>
</div>
)
export default MyCalendar; |
Yes, |
Some additional details after a bit of digging: Something changed in the import behavior for locales in the 2.1.0 release. See this specific commit: 0a9213b So I think your code sample would've worked back in version 2.0 of date-fns, but not 2.1.0 and greater. However, there was a regression bug that broke this between release 2.17 and 2.20.2 (see #2207), allowing that Here's another interesting bit, you can make import { Calendar, dateFnsLocalizer } from 'react-big-calendar'
import format from 'date-fns/format'
import parse from 'date-fns/parse'
import startOfWeek from 'date-fns/startOfWeek'
import getDay from 'date-fns/getDay'
const locales = {
'en-US': require('date-fns/locale/en-US/index'),
'de': require('date-fns/locale/de/index'),
};
const localizer = dateFnsLocalizer({
format,
parse,
startOfWeek,
getDay,
locales,
})
const MyCalendar = props => (
<div>
<Calendar
style={{ height: 500, width: 500, margin: 'auto', }}
localizer={localizer}
culture='de'
startAccessor="start"
endAccessor="end"
events={[]}
/>
</div>
)
export default MyCalendar; |
Same here, ClojureScripts in this case. Require used in (:require
["date-fns/locale/fi" :as fi] With (:require
["date-fns/locale/fi" :default fi] #2207 seems to be the only change in |
hi @croraf I checked the mentioned above versions of the locales and didn't find any changes to the export methods.
or:
Hope it helps! |
For the record, here is a diff between I don't really understand the changes, but something changed regarding the require/imports syntax needed with ClojureScript. Not disputing the close, but just noting observations, in case someone finds those useful. |
@hoxu @tan75 I just got an idea how this came about. In this release, we fixed ESM to enable tree-shaking, and a side effect of it was that now bundlers (i.e., webpack) see ESM versions instead of CommonJS. That broke mixed usage of |
Per date-fns/date-fns#2474, the `date-fns` example in the readme might've been wrong/broken. I am not familiar with your project, so please double-check that this suggestion is OK!
I also tried 2.21.3 (latest current). And the app still breaks.
I'm using
date-fns
forreact-big-calendar
library.To reproduce:
How it supposed to work:
The text was updated successfully, but these errors were encountered: