cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UseDQLQuery autoFetch property

Jwrogers
Newcomer

UseDQLQuery autoFetch set to false still runs query on react component load. Why? 

5 REPLIES 5

haris
Dynatrace Advisor
Dynatrace Advisor

Hi Jwrogers,

can you please give us the code snippet to fully understand the usage? 

Jwrogers
Newcomer

I build the fetch bizEvents DQL in the method getPipelineSummary(), but I don't want it to trigger until I call refetch().

  useEffect(() => {
    setDetails(details);
    refetch();
  }, []);

const { data, isLoading, refetch } = useDqlQuery(
    {
      body: { query: dbQueries.getPipelineSummary() },
    },
    { autoFetch: false, autoFetchOnUpdate: false },
  );

 

imsingh
Dynatrace Advisor
Dynatrace Advisor

Hi there

When the component loads, it calls the `useEffect` hook. In this hook, you're calling refetch. If you dont' want the query to run when component loads, just remove that execution of refetch as following:

 useEffect(() => {
    setDetails(details);
  }, []);

const { data, isLoading, refetch } = useDqlQuery(
    {
      body: { query: dbQueries.getPipelineSummary() },
    },
    { autoFetch: false, autoFetchOnUpdate: false },
  );

I removed refetch from being called anywhere in my component, but it's still being called when the component loads:

Jwrogers_0-1736785232425.png

 



imsingh
Dynatrace Advisor
Dynatrace Advisor

Hi there

Do you have full code snippet that you can share or codesandbox? 
That'll help me solve your issue much better.

Thanks

Featured Posts