Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda