Can I make isFetching true after 500 milliseconds ?
isFetching is useful for show/hide loading UI during fetching but sometimes API response is too quick so the loading UI is displayed and disappeared very fast.
It looks like glitchy. So I wonder if I can have an option to make isFetching true after a certain milliseconds?5 Replies
exotic-emerald•2y ago
One approach I think of is you can use
dataUpdatedAt on the return value of useQuery and if the date is too quick, you can use the select option function to add a little delta time using SetTimeout for the loader to show fully.useQuery | TanStack Query React Docs
const {
data,
exotic-emerald•2y ago
React Query Data Transformations
Learn the possibilities to perform the quite common and important task of transforming your data with react-query
like-goldOP•2y ago
Thanks for the response. The second article is very useful.
Could you please give me some more details regarding of using dataUpdatedAt? I'm not sure how I can use it for displaying a loading UI only when isFetching is longer than 500ms
exotic-emerald•2y ago
If you can share a code env, I can try
like-goldOP•2y ago
Great, thanks!