Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
ReactJs - How to wrap the ApolloProvider inside the StatsigProvider?

In react(nextjs) application, I am using statsig-react to switch the mastergraphql endpoint(urls). Now I am facing an issue while connecting statsig with apollo.

My app.js is like,

const apollo = useApollo(pageProps)

const AddStatsig = () => {
  <StatsigProvider
      sdkKey={`${env.statsigKey}`}
      options={{ environment: { tier: env.environment } }}
      waitForInitialization={true}
   >
     <Component {...pageProps} />
  </StatsigProvider>
}

return (
  <ApolloProvider client={apollo}>
   ...
   <AddStatsig />
   ...
  </ApolloProvider>
)

In apollo.js, I am changing uri like,

import { useGate } from 'statsig-react'

const statsigFeatureOn = useGate('newurl').value

const withAuth = createHttpLink({
  uri: statsigFeatureOn ? statsigPath : oldPath,
  fetch: awsGraphqlFetch,
})

Here, I am getting statsigFeatureOn as false always. And If I check the useGate value in any other component which is wrapped under the StatsigProvider there will get true value(required output).

If I wrap an ApolloProvider under StatsigProvider in a normal way will not get the desired output. I tried few ways and got the different kinds of errors and output.

How can I get true value inside apollo.js at initial load itself?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Move the ApolloProvider and related things into a new component and return that new component within the StatsigProvider in app.js. In new component get and pass the useGate value to useApollo hook.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda