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

168
Views
Apollo useQuery does not always trigger re-render of function component

This is my functional component that makes use of useQuery from @apollo/client:

function MyComponent(props) {
  const { data } = useQuery<MarketScannerSearchProps>(
    MARKET_SCANNER_SEARCH_PROPS_QUERY,
    {
      onCompleted: (data) => {
        console.log("completed", data)
      },
    }
  )
  console.log("data", data)

  // ... rest of function + return rendered result
}

I get this in my console:

data undefined
data undefined

completed {marketScannerSearchProps: {…}}

why isn't there a data {marketScannerSearchProps: {…}} at the end?

This is not always reproducible, only happens every 5th reload or so of my app. This is how it looks when it works:

data undefined
data {marketScannerSearchProps: {…}}
completed {marketScannerSearchProps: {…}}

So somehow the 2nd time the component is rendered the data is there, but not always, and if the data isn't there by the 2nd render, it never updates it afterwards.

Shouldn't apollo trigger a re-render every time once the query completes? What am I missing here?

EDIT: I think this issue might be gone now. I closed and opened Chrome Dev Tools a few times, and now it seems to be gone. Could it be Apollo client side caching getting messed up?

about 4 years ago · Juan Pablo Isaza
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!