Hi! I'm trying to use the GrowthBook DevTools, but...
# contributing
m
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
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
Yes, I can see the interface in the dev tools. Here's console output
f
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
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.