-
Hey, I have a particular question about showing a loading spinner when someone pulls to refresh. I have a screen that I'm polling every 1s ( However, I also want users to be able to pull to refresh. In those cases, I do want to show the refreshing spinner. So, I think I'd want a This is my workaround: function useRefreshableQuery(key, config) {
const isRefreshing = useRef(false)
const query = useQuery(key, {
...config,
refetchInterval: 1000,
onSettled() {
isRefreshing.current = false
}
})
const pullToRefresh = () => {
isRefreshing.current = true
refetch()
}
return Object.assign({}, query, {
get isPullingToRefresh() {
return query.isRefetching && isRefreshing.current
},
pullToRefresh
})
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I think your workaround is good. We don't have a distinction of how a fetch is triggered. |
Beta Was this translation helpful? Give feedback.
-
@nandorojo I'm facing the same issue and tried your solution. However this doesn't work as expected. isPullingToRefresh just returns the same value as isFetching (i.e. it is true even after a refetechInterval refetch). Did you do something else to make it work? |
Beta Was this translation helpful? Give feedback.
I think your workaround is good. We don't have a distinction of how a fetch is triggered.