From cc34834499eddc22c04883d6ac0c34e41b763781 Mon Sep 17 00:00:00 2001 From: Chris Sauve Date: Wed, 17 Apr 2019 13:41:24 -0400 Subject: [PATCH] Make note of ShareTranslations on README --- packages/react-i18n/README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/react-i18n/README.md b/packages/react-i18n/README.md index 430f08b18d..499b5a6db4 100644 --- a/packages/react-i18n/README.md +++ b/packages/react-i18n/README.md @@ -69,6 +69,8 @@ export default function NotFound() { The hook also returns a `ShareTranslations` component. You can wrap this around a part of the subtree that should have access to this component’s translations. +> **Note:** `ShareTranslations` is not guaranteed to re-render when your i18n object changes. If you render `ShareTranslations` inside of a component that might block changes to children, you will likely run into issues. To prevent this, we recommend that `ShareTranslations` should be rendered as a top-level child of the component that uses `useI18n`. + ```tsx import * as React from 'react'; import {Page} from '@shopify/polaris'; @@ -81,13 +83,9 @@ interface Props { export default function ProductDetails({children}: Props) { const [i18n, ShareTranslations] = useI18n(); return ( - - - {children} - - + + {children} + ); } ```