https://www.growthbook.io/ logo
c

colossal-alligator-31194

07/13/2023, 9:17 AM
Hi team. is this a acceptable practice to use multiple useFeature in a page ?
Copy code
const Sample: React.FC = () => {
  const feature1 = useFeature('feature1');
  const feature2 = useFeature('feature2');

  return (
    <>
      <Button color={feature.value || 'blue'}>feature1</Button>
      <Button color={feature.value || 'blue'}>feature2</Button>
    </>
  );
};

export default Sample;
And also do we get experiment for multiple a/b testings in trackingCallback: async (experiment, result) ?
w

white-fireman-22476

07/13/2023, 9:37 AM
the trackingCallback gets called once for each feature.
1
c

colossal-alligator-31194

07/13/2023, 10:05 AM
Thanks, so can I expect two logs in the following code ? ( with enabled namespaces )
Copy code
trackingCallback: async (experiment, result) => {
    console.log(experiment, '<<<<<');
  },
I only see one log for the two experiment:
w

white-fireman-22476

07/13/2023, 10:16 AM
You could expect two logs if both features are in a test. I suspect an A/B test was not set up for one of them.
👀 1
b

better-magician-65629

07/13/2023, 10:56 PM
you may also want to check the FAQ for when the tracking callback gets called as it isn't called in all cases: https://docs.growthbook.io/faq#why-is-the-trackingcallback-not-firing-in-the-sdk