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

careful-grass-28115

09/14/2023, 3:07 PM
Hi, I am working on setting up AB testing 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 true for the current user but when I console.log the value of the flag it is false even though it is true in dev tools.
const enabled = useFeatureIsOn("trackingKey");
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.
b

brief-honey-45610

09/14/2023, 3:19 PM
Hi Tyler, thanks for reaching out! I'll ask one of our engineers who specializes in the Dev Tools feature and get back to you as soon as I can with an update to your question
c

careful-grass-28115

09/14/2023, 4:32 PM
I have added gb.loadFeatures({autoRefresh:true}) but still occasionally I get the wrong variant initially until the page is refreshed
b

brief-honey-45610

09/14/2023, 4:46 PM
Hey Tyler, do you have only one Environment set up in GrowthBook? If you have more than one Environment, as a first debugging step, could you confirm that the Environment you set the Feature Flags in in the dashboard is the same Environment you're using in the Dev Tools pane?
c

careful-grass-28115

09/14/2023, 8:48 PM
Yes I have two environments set up dev and prod. The sdk connection was made with dev and works fine but only when adding an additional environment using the same sdk connection stops working properly. The feature flags show true in the dev console but in the logs show false. Could this be a race condition if there are missing assignment attributes being populated later on page load?
b

brief-honey-45610

09/15/2023, 4:02 AM
Ah! Each environment needs to be using it's own SDK key. Could you please try creating a new production environment with its own SDK key?
c

careful-grass-28115

09/15/2023, 2:30 PM
Yes this is true both env have an sdk connection but the problem is when I am connected to dev after creating prod without switching any connection yet the sdk stops pulling the feature flag value.
14 Views