worried-planet-2191
10/24/2023, 3:45 PMfresh-football-47124
billowy-lizard-55653
10/25/2023, 12:02 PMexport default function App() {
const nonce = useNonce();
const data = useLoaderData();
const [gbLoaded, setData] = useState(null);
useEffect(() => {
// Load features from the GrowthBook API and initialize the SDK
const fetchData = async () => {
await gb.loadFeatures();
const getClientIdPromise = new Promise((resolve) => {
ReactGA.gtag('get', 'G-XXX', 'client_id', resolve);
})
await getClientIdPromise.then((clientId) => {
gb.setAttributes({
clientId,
});
})
setData(gb)
}
fetchData().catch(console.error);
}, []);
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{gbLoaded &&
<GrowthBookProvider growthbook={gbLoaded}>
<Layout {...data}>
< Outlet />
</Layout>
</GrowthBookProvider>
}
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
}