useFlag, useGates, useGatesStatus
useFlag(key, fallback = false)
Returns a boolean: the flag’s value now, evaluated locally. The component re-renders when a sync or an identity change changes the value. Before the local snapshot has been read, and for a flag the snapshot does not contain, it returns fallback.
Reading a flag records one exposure event per flag, revision and user (see Telemetry).
useGates()
Returns the GatesClient from the nearest provider, for flag, explain, identify, reset, refresh, adopt, status and subscribe. Throws if there is no <GatesProvider> above.
useGatesStatus()
Returns the client’s GatesStatus and re-renders when it changes:
| Field | Type | Meaning |
|---|---|---|
ready | boolean | The local snapshot read has been attempted (hit or miss). Evaluation is meaningful from here. |
refreshing | boolean | A refresh() your app asked for is in flight. Background syncs never set it. |
source | "none" | "cache" | "remote" | Where the current flags came from. |
revision | number | The snapshot revision the device holds; 0 before any snapshot. |
syncedAt | number | null | Unix ms of the last successful sync, or of the cached snapshot. |
lastError | string | null | The last sync failure, kept until the next success. Never affects evaluation. |
installationId | string | null | This install’s id, once storage has been read. |
All three hooks live in a module with no react-native import, so they render under vitest with react-test-renderer.