# react-native: useLocaleDirection URL: https://generaltranslation.com/ja/docs/react-native/api/helpers/use-locale-direction.mdx --- title: useLocaleDirection description: useLocaleDirection Hook の API リファレンス --- {/* 自動生成: 直接編集せず、代わりに content/docs-templates/ 内の template を編集してください。 */} ## 概要 `useLocaleDirection` Hook は、[`` コンテキスト](/docs/react-native/api/components/gtprovider) から、現在または指定したロケールの書字方向 (`'ltr'` または `'rtl'`) を取得します。 `useLocaleDirection` はクライアント側の Hook であり、*クライアント側コンポーネントでのみ使用できます*。 アプリが [``](/docs/react-native/api/components/gtprovider) でラップされていることを確認してください。 ## リファレンス ### パラメータ | パラメータ | 型 | 説明 | | -------- | --------------- | --------------------------------------------------------------------- | | `locale` | `string` (省略可) | BCP 47 のロケールコード (例: `'ar'`、`'en-US'`) 。省略した場合は、コンテキストの現在のロケールが使用されます。 | ### 戻り値 `'ltr' | 'rtl'` — ロケールの書字方向。 *** ## 例 ### 現在のロケールの書字方向を取得する ```jsx title="DirectionWrapper.jsx" copy 'use client'; import { useLocaleDirection } from 'gt-react-native'; export default function DirectionWrapper({ children }) { const dir = useLocaleDirection(); // [!code highlight] return
{children}
; } ``` ### 特定のロケールの書字方向を取得する ```jsx title="SpecificDirection.jsx" copy 'use client'; import { useLocaleDirection } from 'gt-react-native'; export default function SpecificDirection() { const dir = useLocaleDirection('ar'); // 'rtl' [!code highlight] return

Arabic text direction: {dir}

; } ``` *** ## 注記 * このHookは常に同期的に動作します。 * RTL をサポートするために、要素の `dir` 属性を設定する際に便利です。 ## 次のステップ