aloof-helicopter-83740
09/14/2023, 12:16 PMuseFeatureIsOn
does that but from what I can see it just calls evalFeature under the hood which per docs calls tracking.
Our use case is that we have specific conditions on when user needs to be enrolled in the experiment so we can't enroll him just to check if feature is on.
For example we have 3 CTAs which change based on the experiment. All of those need to check if feature is on but only one of them should actually trigger enrollment.billions-xylophone-11752
09/14/2023, 1:46 PMaloof-helicopter-83740
09/14/2023, 2:28 PMconst isFeatureEnabled = useIsFeatureEnabled('feature')
{isFeatureEnabled && <ButtonA />}
{isFeatureEnabled && <ButtonB />}
<ButtonC onClick={() => {
growthbook.feature('feature')
} />
In the above feature will be enabled as soon as useIsFeatureEnabled
is called. We want it to get enabled only on ButtonC
click.billions-xylophone-11752
09/14/2023, 2:44 PM<ButtonC />
. But, for the conditional rendering, you need to know if they're in the experiment to know whether to show the buttons.
Is that correct?hasClickedButtonC
, the user would only be bucketed into the experiment (and thus, fire the tracking callback) if that was true. If it wasn't, useIsFeatureEnabled
would just return false without firing the tracking callBack.setAttributes
method - so onClick, you can update the user's attributes. But, you'll want to make sure that the attributes can persist so the next time they land on this page or any others, they have the necessary attributes, otherwise, they might get different variations on subsequent visits.