Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tore-statsig/0bb12b2eb847847af62d547731d2dca9 to your computer and use it in GitHub Desktop.
Save tore-statsig/0bb12b2eb847847af62d547731d2dca9 to your computer and use it in GitHub Desktop.
StatsigManuallyInitializedProvider.tsx
import React from 'react';
import StatsigContext from './StatsigContext';
import Statsig from './Statsig';
type Props = {
children: React.ReactNode | React.ReactNode[];
userVersion: number;
};
export default function StatsigManuallyInitializedProvider({
children,
userVersion,
}: Props): JSX.Element {
return (
<StatsigContext.Provider
value={{
initialized: true, // or whatever determines this state
statsigPromise: null,
userVersion, // bump this when the user is updated to force a rerender
initStarted: Statsig.initializeCalled(),
}}
>
{children}
</StatsigContext.Provider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment