I am using React query on a React app that makes multiple paralell requests. Every time I hit tab to go to another app or page, it removes all the dashboards and shows spinner. It refetches all the data and makes all the requests again even when the keyword in the search bar has not changed and, therefore, it is not useful to make the user wait for another few seconds to be able to see the dashboards.
1 Answer
disabling refetch on focus might help you, but I would remove isFetching at all and left only isLoading
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
},
},
})
source: https://react-query.tanstack.com/guides/window-focus-refetching
isFetchingis doing, and you don’t want that, then yes, I’d suggest to remove that :)