Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattsputnikdigital opened this issue Apr 13, 2024 · 1 comment

Comments

@mattsputnikdigital
Copy link

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

@TkDodo
Copy link
Collaborator

TkDodo commented Apr 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants