24 Nov 2024 11:59 PM
UseDQLQuery autoFetch set to false still runs query on react component load. Why?
25 Nov 2024 11:15 AM
Hi Jwrogers,
can you please give us the code snippet to fully understand the usage?
25 Nov 2024 01:25 PM
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 },
);
25 Nov 2024 04:08 PM - edited 25 Nov 2024 04:09 PM
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 },
);