-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
212a7c9
commit c801293
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Tabs from "@theme/Tabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
|
||
## Loading State | ||
|
||
Dependent on your setup, you may want to wait for the latest values before checking a gate or experiment. | ||
If you are using the `StatsigProviderRN`, you can pass in a `loadingComponent` prop to display a loading state while the SDK is initializing. | ||
If you are using the `useClientAsyncInitRN` hook, you can check the `isLoading` prop to determine if the SDK is still loading. | ||
|
||
|
||
<Tabs | ||
defaultValue="provider" | ||
groupId="react-usage-choice" | ||
values={[ | ||
{label: 'StatsigProviderRN', value: 'provider'}, | ||
{label: 'useClientAsyncInitRN', value: 'client'}, | ||
]}> | ||
|
||
<TabItem value="provider"> | ||
|
||
```tsx | ||
export function App() { | ||
const loadingComponent = <div>Loading...</div>; | ||
|
||
return ( | ||
<StatsigProviderRN | ||
... | ||
loadingComponent={loadingComponent} // <- Pass in the loading component | ||
> | ||
<YourComponent /> | ||
</StatsigProviderRN> | ||
); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="client"> | ||
|
||
```tsx | ||
export function App() { | ||
const { client, isLoading } = useClientAsyncInitRN(...); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
return ( | ||
<StatsigProviderRN client={client}> | ||
<YourComponent /> | ||
</StatsigProviderRN> | ||
); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|