i have been watching some tutorials on useQuery and everyone seems to use `isLoading`, my issue is t
i have been watching some tutorials on useQuery and everyone seems to use
isLoading, my issue is that when a refetch happens i need to also watch for isRefetching in order for my component to update with new data (after calling invalidateQueries), am i doing something wrong ? i was thinking about using fetchStatus instead of isLoading and but i am not sure if this will lead to some useless re-renders
in some component i call queryClient.invalidateQueries(), then i go to another page (using react-router-dom HashRouter) which should update with new data, i see the api call with the fresh data
a simple code example
const {data, isLoading, fetchStatus } = useQuery(['someData'], fetchSomeData)
// won't update if data changes after a refetch
return (!isLoading &&
<div>
{data &&
... render the component
}
</div>)
// will update immediately
return (fetchStatus !== 'fetching' &&
<div>
{data &&
... render the component
}
</div>)
P.S. i am new to react and react-query1 Reply
xenial-black•3y ago
Read TkDodos blog…