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

298
Views
Should the arguments passed to react-query's useQuery hook be referentially stable?

I am going through an existing codebase, looking at some data fetching hooks that use useQuery

I am noticing that, almost everywhere, care is taken so that the arguments passed in the useQuery hook (and other similar react-query hooks) are referentially the same between hook executions.

For example

//custom_data_fetching_hook.js

import { useQuery } from 'react-query';

function fetchSomeStuff() {
  // server data request implementation
}

const queryOptions = {
 // object as described in the 3rd argument here:
 // https://react-query.tanstack.com/reference/useQuery
};

export function useSomeServerStuff() {
  return useQuery(['query key'], fetchSomeStuff, queryOptions);
}

My question is this:

Is it necessary to ensure referential stability for the useQuery, useMutation, etc, arguments? As far as I could tell the docs do not say you should do this.

Would the react-query hooks redo calculations on every component re-render if their arguments are not referentially the same between renders?

Would the react-query hooks return some referentially different items within their return object value if their arguments are not referentially the same between renders? (for example the mutate function inside the return object of useMutation)

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!