Last active
August 9, 2023 20:20
-
-
Save juliandavidmr/c8f537b6083577a262609894d0712fbf to your computer and use it in GitHub Desktop.
2022 useExperiment.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 { useContext } from 'react'; | |
import { | |
AmplitudeExperimentContext, | |
AmplitudeExperimentContextValue, | |
} from './ExperimentContext'; | |
const useExperiment = (): AmplitudeExperimentContextValue => { | |
const context = useContext(AmplitudeExperimentContext); | |
if (context === undefined) { | |
throw new Error( | |
'useExperiment must be used within a AmplitudeExperimentProvider', | |
); | |
} | |
return context!; | |
}; | |
export default useExperiment; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment