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