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

246
Vistas
Control html dynamically without component re rendering in React with Apollo

In my current situation, I use Apollo useQuery to fetch a user and their posts.

The posts render in a summary view and in a detailed view. the detailed view is sitting on top of the summary view and its visibility is controlled by a piece of state.

  const { data: userData, error: userError } = useQuery(GET_USER_BY_ID, { // the data fetch
    variables: {
      userId: getUserId(),
    }
  })


  const [showPosts, setShowPosts] = useState(false) // controls toggle between views

the problem im having is every time the showPosts state changes the component re renders and the useQuery is run again. which I do not want. I have already got all my data, I just want to render html without hitting the server again until I need to. What is a potential solution to my problem?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Check skip param, You can do something like this:

const { data: userData, error: userError } = useQuery(GET_USER_BY_ID, { // the data fetch
        variables: {
          userId: getUserId(),
          skip:!showPosts
        }
      })

or use useLazyQuery

about 4 years ago · Santiago Trujillo 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