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

106
Visualizações
useQuery parameter dependent on data from another useQuery

I have the following useQuery function

const useQueryBlob = (url: string) => {
  return useQuery<Blob>(
    'blob',
    async () => {
      const { data: blob } = await axios.get<Blob>(url, { responseType: 'blob' });
      return blob;
    },
  );
};

The url I want to pass is someData from useQueryTest

  const { data: someData } = useQueryTest('test');
  const { data: blob } = useQueryBlob(someData);

However, someData is always undefined on the first render so the url passed to useQueryBlob is also undefined.

How do I make sure that the url passed to useQueryBlob is not undefined on the first render?

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

0

You can make use of the enabled boolean. This will disable the query from automatically running until the enabled is set to true.

useQuery docs

const useQueryBlob = (url: string | undefined) => {
  return useQuery<Blob>(
    'blob',
    async () => {
      const { data: blob } = await axios.get<Blob>(url, { responseType: 'blob' });
      return blob;
    },
    { enabled: !!url }
  );
};
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