From f783c5ec53120e38ca27a00c5e4c03d7112b22a9 Mon Sep 17 00:00:00 2001 From: tore-statsig <74584483+tore-statsig@users.noreply.github.com> Date: Tue, 20 Aug 2024 08:25:39 -0700 Subject: [PATCH] simplify react setup docs --- docs/client/javascript-mono/_reactSetup.mdx | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/docs/client/javascript-mono/_reactSetup.mdx b/docs/client/javascript-mono/_reactSetup.mdx index 6ed86695e..7eeb5cb75 100644 --- a/docs/client/javascript-mono/_reactSetup.mdx +++ b/docs/client/javascript-mono/_reactSetup.mdx @@ -7,14 +7,8 @@ To use Statsig in React, you first must create an instance of the Statsig client This will set your client as part of the [StatsigContext](https://github.com/statsig-io/js-client-monorepo/blob/main/packages/react-bindings/src/StatsigContext.ts) and make it available to all Statsig [hooks](#hooks). -### Asynchronous Initialization (Network) - -When calling StatsigClient.initializeAsync, the client will load values from cache and provide them to the client. The client will then fetch the latest values from the network, providing the ability to await the latest values from Statsig. - -If you want the latest values, but do not want to await the asynchronous call, you may call initializeAsync and simply .catch the promise. Note that this could lead to values changing mid-session as newer values arrive from the network. - -Note: To learn more about sync vs async initialization and how it can be customized, see [Using EvaluationsDataAdapter](/client/javascript-sdk/using-evaluations-data-adapter) - +### Initialize +Call `StatsigClient.initializeAsync` and wait for the result to get the most up to date values from the network. ```js function Content() { @@ -58,10 +52,3 @@ export default function AsyncInitializeExample(): JSX.Element { ); } ``` - - -### Synchronous Initialization (Cache) - -When calling StatsigClient.initalizeSync, the client will attempt to use cache values if they are available. The client will also fetch new values in the background and update the cache (not the current in-use values). In practice, unless an additional update call is made, this means that for the very first session of a given user, there will be no values, and not until the next session will the cache have values. - -