Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
Rendered more hooks than during the previous render after apollo useQuery

I'm tying to find a way to correct the Hook rendering error. I have a total of 3 useQuery hooks being rendered :

   const {
        data: OSData,
        error: OSError,
        loading: OSLoading,
      } = useQuery(OSData, {

        variables: {
          NUMBER: UniqueList,
        },
      })

      const {
        data: RamData,
        error: RamERROR,
        loading: RamLOADING,
      } = useQuery(GET_Ram)

    
      const {
        data: Hardware,
        error: HardwareERROR,
        loading: HardwareLOADING,
      } = useQuery(GET_Hardware)

The variable 'NUMBER' is based on a list 'UniqueList' that is made from the GET_Ram and GET_Hardware queries so the OSData query needs to be called later or there's an undefined variable. However, calling the OSData Query later in the code gives me a render error.

Any idea on how I could accomplish this?

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

an answer I found is using lazy query.

       const SomeData [{
            called, loading, data
          }] = useLazyQuery(OSData)
          })

  if (called && loading) return <p>Loading ...</p>

  if (HardwareLOADING || RamLOADING) return <p> loading</p>
  if (HardwareERROR || RamERROR) return <p>error</p>


//perform all the needed calculations for the variable here

and in the return statement you can call the query and provide the variable. Here I use a button.

<div>
  <button onClick={() => SomeData({ variables: { NUMBER: uniqueList } })}>
    Load{' '}
  </button>
</div>

Hope this helps someone

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda