Skip to content

Instantly share code, notes, and snippets.

@jhannes
Last active October 29, 2020 23:02
Show Gist options
  • Save jhannes/750a82407ea10263d57caf0eb7c8a03b to your computer and use it in GitHub Desktop.
Save jhannes/750a82407ea10263d57caf0eb7c8a03b to your computer and use it in GitHub Desktop.
Localization with TypeScript and React context
function MainPage() {
const { standardTexts, personTexts: texts } = useContext(
ApplicationTextsContext
);
return (
<div>
<h2>{texts.header}</h2>
<div>
<label>{texts.givenName}:</label>
<input />
</div>
<div>
<label>{texts.familyName}:</label>
<input />
</div>
<div>
<label>{texts.title}:</label>
<input />
</div>
<button>{standardTexts.submit}</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment