Back

gt-react-native@10.20.0

Ernest McCarter avatarErnest McCarter
gt-react-nativelocalenative-store

Overview

gt-react-native 10.20.0 adds getLocaleFromNativeStore() — a synchronous function that reads the persisted locale from the native store without needing React context.

Usage

import { getLocaleFromNativeStore } from 'gt-react-native';

// Read the persisted locale
const locale = getLocaleFromNativeStore();
// => 'en-US' | null

If your GTProvider uses a customised localeCookieName, pass the same key:

const locale = getLocaleFromNativeStore('my-custom-key');

⚠️ Sync caveat

The native store value can be out of sync with React state. During a locale change, the store may still hold the old value (or vice versa). Use this where you need a quick imperative read and can tolerate stale data — for reactive updates, use useLocale() instead.


PR #1537