Skip to content

Use your translations

Now that you have created your translations, you can use them in your components.

Using the withTranslations higher-order component, you can assign your translations to a component. This component will then receive a getTranslations function as a prop which will return your translations.

const withExampleTranslations = withTranslations(exampleTranslations);
const TranslatedComponent = () =>
withExampleTranslations(({ getTranslations }) => {
const { Greeting } = getTranslations();
return <p>{Greeting()}</p>;
});