TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.

Home Page:https://tanstack.com/query

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enabled: false should not ever fire a query or populate the local store

mattsputnikdigital opened this issue · comments

Describe the bug

I am having issues with useLoaderData having its promise (from React Query) cancelled due to a useQuery / subscription sitting above the route in question that would like to access the infinite data once it is populated. This then ruins the suspense / await component functionality as errors are propagated.

This is just to display a little bit of info in the header that would come from the infinite data total records count.

I have tried every different way to access the local store and setting enabled: false and not providing a queryFn would seem like the answer but it still fires a query with then creates a local version of empty data which causes other issues when the real query is fired.

I would like a way to either totally disable a query from ever running until a condition, such as data existing / or an active query running elsewhere. There doesn't seem to be a way to achieve this.

Your minimal, reproducible example

Sorry

Steps to reproduce

Unable to build a working demo at the moment

Expected behavior

I would like a way to totally disable a query and just return undefined if no data is already populated.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

All platforms, all browsers

Tanstack Query adapter

react-query

TanStack Query version

^5.29.2

TypeScript version

5.4.5

Additional context

No response

I don't understand the issue so I'd need to see a reproduction to continue here please