T
TanStack3y ago
implicit-lime

await query without fetching it

I have a component that uses a useQuery for a given query. In order to handle user input, I need to use that data. I don't want to just error in the event that the data is not yet fetched, or discard the input. I know I can just use await queryClient.fetchQuery(blah) in the user input handler. but my understanding is that this will make a second network request, if the first one (from the hook) hasn't returned yet. is that true? I know it won't if there's already data that isn't stale.
2 Replies
vicious-gold
vicious-gold3y ago
Disabling/Pausing Queries | TanStack Query Docs
If you ever want to disable a query from automatically running, you can use the enabled = false option. When enabled is false:
implicit-lime
implicit-limeOP3y ago
I think I was just wrong that a second network request would be made. Thanks!

Did you find this page helpful?