Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!