question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Locale prop not used

See original GitHub issue

Expected behavior

I would like to use locale prop in my DatePicker, just like in the example:

        <DatePicker
          selected={this.state.startDate}
          onChange={this.handleChange}
          locale="fr"
          todayButton={"Aujourd'hui"}
        />

But, it seems to not work because it is still in English. My dependencies are:

    "moment": "2.21.0",
    "react": "16.2.0",
    "react-dom": "16.2.0",
    "react-datepicker": "1.2.2"

Steps to reproduce

I created a simple example in this CodeSandBox: https://codesandbox.io/s/5383o29jpx.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
indapubliccommented, Mar 15, 2018

Fixed by importing moment locale

import moment from 'moment'
import 'moment/locale/ru'
moment.locale('ru')
1reaction
kkras3commented, Sep 29, 2018

Now wait… I simply set moment locale moment.locale('fr') and in the datepicker

<Datepicker
    locale={'fr'} 
        ... 
/>

and it just works. No need to import the locale resources.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-intl for non components - Stack Overflow
Currently I have the following code to expose react-intl to non-components, but it throws an error for intl as undefined. I have created...
Read more >
react-native-community/datetimepicker - npm
By default, the device's locale is used. Please note using this prop is discouraged due to not working reliably in all picker modes....
Read more >
Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >
Provider - React Spectrum - Adobe
Provider is the container for all React Spectrum applications. It defines the theme, locale, and other application level settings, and can also be...
Read more >
How to validate React props using PropTypes - LogRocket Blog
Just like a function might have mandatory arguments, a React component might require a prop to be defined, otherwise, it will not render ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found