Hi all :wave:, We are working on setting up AB exp...
# ask-questions
p
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
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
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
Are you using the JS or React SDK?
p
The Js one
s
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
We have a vanilla JS codebase, so, perhaps can you help me with a method similar to
setRenderer
but for the JS one?
s
You can use setRenderer - its part of the JS SDK. I would re-set your FF values in the setRenderer callback
🙌 1
p
Ok, let me try that out, Thank you 🙌