enabled flag for queryClient.prefetchQuery #4791
-
Hello everybody. I've been using A common thing that I saw myself doing is, when I have to prefetch, I normally want to await for my main query to finish so it gets prioritized on the network and after that, I call the prefetch. But, right now, I have to wrap my prefetch function in a condition in order for it waits its time.
Let me know if you guys think that makes sense, if so I would love to contribute! And thanks for all your hard work in making this library, it's really amazing! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The only reason why Also, |
Beta Was this translation helpful? Give feedback.
The only reason why
useQuery
has anenabled
option is because you can't call it conditionally, as it's a hook. You can just wrapqueryClient.prefetchQuery
in anif
statement and not call it instead.Also,
enabled
is an Observer level property, andprefetchQuery
doesn't create aQueryObserver
- it just fetches data and puts into the cache once.