https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
p

powerful-shampoo-80729

10/19/2023, 1:21 PM
Hi all 👋, We are working on setting up AB experimentation using feature flags and am running into an issue using the feature flag. Using growthbook dev tools I see that the feature flag is set to a particular variant for the current user but when I console.log the value of the flag it is still the one that loaded initially even though it is overidden in dev tools. I also have logged the results received in the tracking callback. This is my first time using growthbook and might be missing something simple. Why could this be happening? The enviroment is enabled,
trackingKey
matches, changes are published.
More background info here - We are using 3 different environments with sdks installed separately for each of these and also using
growthbook.loadFeatures({ autoRefresh: true })
but no change in UI is seen when overriding the variant from dev tools.
s

swift-helmet-3648

10/19/2023, 4:23 PM
Hi Ustatleen, it might have to do with how you're accessing the feature. Just to clear up confusion,
autoRefresh
is to enable our SSE feature to allow for real-time events. It's not related to how DevTools will override features. Are you able to provide a snippet of the code you're using to access / render the feature? It's possible that your app is not re-rendering after updating the feature value.
p

powerful-shampoo-80729

10/20/2023, 5:41 AM
Hey, here is my implementation
Copy code
await growthbook.loadFeatures({ autoRefresh: true }).then(() => {
      const ft = growthbook.context?.features;
      (Object.keys(ft || {}) || []).forEach(key => {
        growthbook.isOn(key);
      });
    });
s

swift-helmet-3648

10/20/2023, 4:19 PM
Are you using the JS or React SDK?
p

powerful-shampoo-80729

10/24/2023, 11:04 AM
The Js one
s

swift-helmet-3648

10/24/2023, 3:56 PM
My suspicion is that your code is not re-evaluating the feature after being overridden, so the first value persists no matter what. With our React SDK, we leverage some of the react API to trigger a re-render which ends up re-evaluating. Perhaps you could make use of
setRenderer
method we provide, docs here: https://docs.growthbook.io/lib/js#re-rendering-when-features-change
1
p

powerful-shampoo-80729

10/25/2023, 7:50 AM
We have a vanilla JS codebase, so, perhaps can you help me with a method similar to
setRenderer
but for the JS one?
s

swift-helmet-3648

10/25/2023, 4:42 PM
You can use setRenderer - its part of the JS SDK. I would re-set your FF values in the setRenderer callback
🙌 1
p

powerful-shampoo-80729

10/26/2023, 7:01 AM
Ok, let me try that out, Thank you 🙌
2 Views