Calling suspense on a query ignores the `enabled` config option
See original GitHub issueVersion: 2.0.0-beta.5
Possibly related to #200.
When calling useQuery({ enabled: false })).suspense()
the query will run regardless of the enabled
value being false
.
Context:
I’m chaining query calls like this:
const enabled: Ref<boolean> = ... // Some reactive value from somewhere, ie Provide/Inject
const data = await useQuery({ enabled }).suspense()
My intent is to suspend the component from loading until enabled is set to true. In my case, I’m waiting on a global auth state to become true.
I’ll be happy to help contribute in a PR.
Side issue: Does the dev tools update the state of the options if the options are reactive and change? It doesn’t seem to update in my case.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
new useQueries API · Issue #2923 · TanStack/query
just taking an Array of useQuery objects doesn't cover all the cases, because some options have to be the same for all queries,...
Read more >Disabling/Pausing Queries
The query will ignore query client invalidateQueries and refetchQueries calls that would normally result in the query refetching. refetch returned from useQuery ...
Read more >Hooks - Apollo GraphQL Docs
A callback function that's called when the query encounters one or more errors (unless errorPolicy is ignore ). This function is passed an...
Read more >Suspense for Data Fetching (Experimental)
We call this approach “fetch-on-render” because it doesn't start fetching until after the component has rendered on the screen. This leads to a...
Read more >react-query/README.md
To enable this mode, you can set either the global or query level config's `suspense` option to `true`. 999. 1000, Global configuration:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@DamianOsipiuk I can confirm it is fixed! Cheers
@SyntheticGoop @kevin-courbet @rompetomp Please try https://github.com/DamianOsipiuk/vue-query/releases/tag/v2.0.0-beta.7 and let me know if it fixes your issue.