Created
August 9, 2023 20:12
-
-
Save juliandavidmr/77839a29c85574d2f4b112161ee5c292 to your computer and use it in GitHub Desktop.
2022 ExperimentContext.ts
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
import { createContext } from 'react'; | |
import { ExperimentClient } from '@amplitude/experiment-js-client'; | |
export interface AmplitudeExperimentContextValue { | |
experiment?: ExperimentClient; | |
isVariantActive: (variantId: string, variantValue?: string) => boolean; | |
/** | |
* @description Returns true if the user is in the experiment with variant `control`. | |
*/ | |
isControlActive: (variantId: string, defaultControl?: string) => boolean; | |
getPayloadVariant: <T>(variantId: string) => T | null; | |
} | |
export const AmplitudeExperimentContext = | |
createContext<AmplitudeExperimentContextValue | null>(null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment