08/10/2023, 5:10 PM
Hiya, does anyone know what is the recommended way to use GrowthBook in a class component?
I found a way to do it, by creating a “helper” function component which can be included in the class component. Pass it the name of the feature you want to check, and a callback function. Posting here in case it helps someone else - I see this question has been asked before. This updates if you manually change the feature value in the GrowthBook devtools.
*export const* _IsFeatureOn_ = ({
setIsFeatureOn, _// callback function to set value in parent component state_
}: IsFeatureOnProps) => {
*const* isFeatureOn = _useIsFeatureOn_(featureName);
_useEffect_(() => {
}, [isFeatureOn]);
*return* <></>;