sajad torkamani

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