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? 

3 REPLIES 3

haris
Dynatrace Helper
Dynatrace Helper

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 },
  );

Featured Posts