-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
useIsFetching always returns false #3437
Comments
🎉 This issue has been resolved in version 3.34.17 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 4.0.0-alpha.22 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@TkDodo the 3.34.17 have fixed for you? I'm using the 3.38.0 and the |
Yes, try out the sandbox with the latest version. |
Hmm, I discovered that always returns 0 when I pass more than one key like: queryClient.isFetching(['firstKey','secondKey']) so I think that is not supported or I'm doing something wrong Did you know if there's some way to watch for multiples specific queries? |
If you want to target multiple keys, you'd need to use the predicate function argument, or call the hook twice. |
do you have a demo? |
|
Describe the bug
useIsFetching
always shows zero when loading for the first time.Your minimal, reproducible example
https://codesandbox.io/s/react-query-starting-point-forked-zz56e1?file=/src/App.tsx
Steps to reproduce
look at the sandbox
isFetching should be true at some point, but it's not
note that it works if you change the order of
Example
andGlobalFetchingIndicator
Expected behavior
useIsFetching
should show the correct fetching countHow often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
all of them
react-query version
v3 and v4
TypeScript version
No response
Additional context
it seems that subscription order is important. We check for
isFetching
when the hook mounts, and then again inside the subscription in the effect. However:A potential solution could be to check for
queryClient.isFetching
once again if the effect runs, but outside of the subscription.The text was updated successfully, but these errors were encountered: