React-big-calendar: dateFnsLocalizer is not working

Created on 13 Aug 2020  路  5Comments  路  Source: jquense/react-big-calendar

const locales = {
  'zh-TW': require('date-fns/locale/zh-TW'),
}

my package.json

"date-fns": "^2.15.0",
"react-big-calendar": "^0.26.0",
"typescript": "~3.7.2"

It always show en-US in calendar. It that bug?

Most helpful comment

@pig800509 You should pass culture={"zh-TW"} as a prop to <Calendar/>

Does not work, it causes: Uncaught RangeError: locale must contain localize property

"react-big-calendar": "^0.28.0",
"date-fns": "^2.16.1",

https://codesandbox.io/s/gifted-driscoll-ye7rn

All 5 comments

I have this same problem

@pig800509 You should pass culture={"zh-TW"} as a prop to <Calendar/>

@pig800509 You should pass culture={"zh-TW"} as a prop to <Calendar/>

Does not work, it causes: Uncaught RangeError: locale must contain localize property

"react-big-calendar": "^0.28.0",
"date-fns": "^2.16.1",

https://codesandbox.io/s/gifted-driscoll-ye7rn

Try importing the locale object via namespace import

import { zhTW } from 'date-fns/locale'

and then using it like this:

const locales = {
  'zh-TW': zhTW
}

Try importing the locale object via namespace import

It works now: https://codesandbox.io/s/fast-breeze-ckmf4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Beyazatli picture Beyazatli  路  3Comments

zhming0 picture zhming0  路  3Comments

mathieusanchez picture mathieusanchez  路  4Comments

The-Oracle picture The-Oracle  路  3Comments

manutenfruits picture manutenfruits  路  3Comments