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

299
Visualizações
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
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