Change locale in react-datepicker

后端 未结 6 1150
一向
一向 2021-02-04 03:30

I am using react-datepicker NPM package,
I tried to follow documentation but I was unable to import

registerLocale 

and

         


        
6条回答
  •  生来不讨喜
    2021-02-04 03:38

    For dynamic locale imports you could use this code. However, you will get a larger package with dynamic imports:

    constructor(props) {
        const getLocale = locale => require(`date-fns/locale/${this.props.language}/index.js`)
        this.locale = getLocale(this.props.language);
    }
    

    And then use

    
    

提交回复
热议问题