Skip to content

Commit

Permalink
docs: update react native guide according to example (#2071)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak authored Oct 29, 2024
1 parent e726b16 commit d0e45bc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions website/docs/tutorials/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ Not surprisingly, this part isn't too different from the [React tutorial](/docs/
First, we need to wrap our app with [`I18nProvider`](/docs/ref/react.md#i18nprovider) and then we can use the [`Trans`](/docs/ref/macro.mdx#trans) macro to translate the screen heading:

```tsx
import { I18nProvider } from "@lingui/react";
import { I18nProvider, TransRenderProps } from "@lingui/react";
import { Trans } from "@lingui/macro";
import { i18n } from "@lingui/core";
import { Text } from "react-native";

i18n.loadAndActivate({ locale: "en", messages });

<I18nProvider i18n={i18n} defaultComponent={Text}>
const DefaultComponent = (props: TransRenderProps) => {
return <Text>{props.children}</Text>;
};

<I18nProvider i18n={i18n} defaultComponent={DefaultComponent}>
<AppRoot />
</I18nProvider>

Expand Down

0 comments on commit d0e45bc

Please sign in to comment.