React Query: Check if any queries are fetching
6 June 2022 (Updated 6 June 2022)
Use the useIsFetching
hook to check if any queries are fetching (including background fetches):
import { useIsFetching } from 'react-query'
function GlobalLoadingIndicator() {
const isFetching = useIsFetching()
return isFetching ? (
<div>Queries are fetching in the background...</div>
) : null
}
Sources
Tagged:
React Query
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment