Material-ui-pickers: Localization always showing 'my' if 'moment/locale/my' is imported.

Created on 26 Jul 2019  路  2Comments  路  Source: mui-org/material-ui-pickers

http://gph.is/2r8kLhO
Me explaining how my react app works

Environment

| Tech | Version |
| -------------------- | ------- |
| @material-ui/pickers | 2.2.4 |
| material-ui | 4.2.1 |
| React | 16.8.0 |
| Chrome | 75.0.3770.142 |
| moment | 2.24.0 |
| @date-io/moment | 1.3.8 |

Steps to reproduce

  1. import "moment/locale/my" and import "moment/locale/es" in a react component.
  2. MuiPickersUtilsProvider utils={MomentUtils} locale="es"... (or set the locale in the state, etc.)

Expected behavior

If es (or any other locale) is passed as the locale, it should render in that locale.

Actual behavior

If moment/locale/my is imported into the component, the locale is set to 'my' even if no locale is passed or if a specific other locale is passed. If I remove import "moment/locale/my"; from my component, then it behaves as expected, so I think it something specific to this locale.

Live example

https://codesandbox.io/s/material-ui-pickers-usage-demo-94rhf

Most helpful comment

I think I noticed this same problem right on the demo page: https://material-ui-pickers.dev/localization/moment

Regardless of which locale you pick, nothing changes.

All 2 comments

I think I noticed this same problem right on the demo page: https://material-ui-pickers.dev/localization/moment

Regardless of which locale you pick, nothing changes.

The live example of the OP seems to be working. I am able to switch between 'my' and 'en' in that codesandbox.

However on the demo page as pointed out by @macpham it's not working. But the odd thing is that in a codesandbox, that exact same code is working: https://codesandbox.io/s/goofy-minsky-y51gy

But using the date library dayjs it isn't. Live example using dayjs where the problem is also present: https://codesandbox.io/s/clever-field-2gzmf

Another live example using an exact same setup as dayjs, but then using moment and the problem is solved: https://codesandbox.io/s/young-snow-ejinu

Was this page helpful?
0 / 5 - 0 ratings