# react-native: getLocaleFromNativeStore URL: https://generaltranslation.com/ja/docs/react-native/api/helpers/get-locale-from-native-store.mdx --- title: getLocaleFromNativeStore description: React contextを使わずに、ネイティブストレージに保存されているロケールを読み取ります。 --- ## リファレンス ```jsx import { getLocaleFromNativeStore } from 'gt-react-native'; const locale = getLocaleFromNativeStore(key?); // => 'en-US' | null ``` ### パラメーター | パラメーター | Type | 説明 | | ------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `key` | `string?` | 読み取り元のストレージキーです。デフォルトは `'generaltranslation.locale'` です。 [``](/docs/react-native/api/components/gtprovider) でカスタムの `localeCookieName` を使用している場合は、ここにも同じ値を渡してください。 | ### 戻り値 `string | null` — 保存されているロケール文字列。ロケールが保存されていない場合は `null`。 *** ## 使い方 ```jsx copy import { getLocaleFromNativeStore } from 'gt-react-native'; const locale = getLocaleFromNativeStore(); ``` `GTProvider` でカスタムの `localeCookieName` を使用している場合は、同じキーを渡してください。 ```jsx copy const locale = getLocaleFromNativeStore('my-custom-key'); ``` ロケールの変更中は、ネイティブストアの値が **React の state と同期ずれを起こす**ことがあります。変更をリアクティブに反映するには、代わりに [`useLocale`](/docs/react-native/api/helpers/use-locale) を使用してください。