UseDQLQuery autoFetch set to false still runs query on react component load. Why?
Hi Jwrogers,
can you please give us the code snippet to fully understand the usage?
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 },
);
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 },
);
Hi there
Do you have full code snippet that you can share or codesandbox?
That’ll help me solve your issue much better.
Thanks
