https://www.growthbook.io/ logo
#contributing
Title
# contributing
m

melodic-quill-31019

05/12/2022, 1:23 PM
Hi! I'm trying to use the GrowthBook DevTools, but it seems like changing the current value of a feature flag in the DevTools does not have any effect on my application (also reloading has no effect). This is my provider implementation (running on Next.js v12.1.6):
Copy code
import { ReactNode, useEffect } from "react";
import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react";
import { useUser } from "src/lib/auth";
import useSWR from "swr";

const growthbook = new GrowthBook();

async function fetcher() {
  const res = await fetch(process.env.NEXT_PUBLIC_GROWTHBOOK_FEATURES_ENDPOINT);
  if (res.status !== 200) {
    return null;
  }
  const result = await res.json();
  return result?.features;
}

export default function MyGrowthBookProvider({
  children,
}: {
  children: ReactNode;
}) {
  const { data: featureFlags } = useSWR("feature-flags", fetcher);
  const user = useUser();

  useEffect(() => {
    growthbook.setFeatures(featureFlags);
  }, [featureFlags]);

  useEffect(() => {
    growthbook.setAttributes({
      id: user.data?.id,
    });
  }, [user.data]);
  return (
    <GrowthBookProvider growthbook={growthbook}>{children}</GrowthBookProvider>
  );
}
<MyGrowthBookProvider />
is used in
_app.tsx
(wrapping
<Component />
) The feature flagging works fine, only the dev tool doesn't have any effect.
f

future-teacher-7046

05/12/2022, 1:32 PM
If you see the list of features in dev tools, that means it's interfacing with the GrowthBook instance on your site. So the problem must be elsewhere. Can you try changing a feature value in dev tools and then in the console, do
Copy code
_growthbook._forcedFeatureValues
to see if it's being set.
m

melodic-quill-31019

05/12/2022, 1:36 PM
Yes, I can see the interface in the dev tools. Here's console output
f

future-teacher-7046

05/12/2022, 1:42 PM
Hmm, that's strange. So either the postmessage from dev tools is failing (which would be weird since it's getting the list of features) or there are multiple instances of GrowthBook and the dev tools is referencing a different one than your app is using
Is this the only place in your app where you are doing
new GrowthBook()
?
m

melodic-quill-31019

05/12/2022, 2:28 PM
Thanks for your help, @future-teacher-7046, really appreciated 🙏 Yes, there's only one place where I'm calling
new GrowthBook()
. I had another one running in a
_middleware.ts
(which should not run in the frontend), but I removed it to be sure that this is not the problem.
32 Views