0 votes
in ReactJS by

How to access current locale with React Intl?

1 Answer

0 votes
by

You can get the current locale in any component of your application using injectIntl():

import { injectIntl, intlShape } from 'react-intl'

const MyComponent = ({ intl }) => (
  <div>{`The current locale is ${intl.locale}`}</div>
)

MyComponent.propTypes = {
  intl: intlShape.isRequired
}

export default injectIntl(MyComponent)

Related questions

0 votes
asked Mar 3, 2020 in ReactJS by miceperry
0 votes
asked Mar 2, 2020 in ReactJS by RShastri
...