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

279
Vistas
ReactJS - How to return a string from functional component?

In react, I am using @apollo/client for backend APIs. In appollo.js I am trying to call backend API link based on condition.

Right now appollo.js contains only functions, its not a component.

I am trying add statsig feature to it, const featureOn = useGate(<FEATURE_GATE_NAME>).value;

How can I use statsig variable inside appollo.js?

Also I have tried by creating separate component and rendering like <AbcComponent />, but its not return a required value.

AbcComponent.js,

export const AbcComponent = () => {
  const featureOn = useGate('abc').value
  return featureOn ? 'Yes' : 'no'
}

In this scenario, how can I get 'Yes/No' from appollo.js?

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

0

Component in react should always return a JSX . what you need here is a custom hook.

export const useCheckFeatureOn = () => {
    const featureOn = useGate('abc').value
    return featureOn ? 'Yes' : 'no'
  }

Use the above hook wherever you want to consume the value

const isFeatureOn = useCheckFeatureOn();
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