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

102
Views
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 answers
Answer question

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 Report
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!