React Core & Hooks (407 Qs)•Part 2: React Router & Navigation (78 - 88)
How to access current locale with React Intl?
mid LevelCode ExampleRouting
You can get the current locale in any component of your application using injectIntl():
jsx
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);