NProgress with React Query
I wanted to add NProgress bar for every ajax call (whether it be query or mutation).
What's the easiest way to tap into react query's cycle of initiating call and finishing it to inject
NProgress.start() and NProgress.done() handlers?2 Replies
like-gold•3y ago
TanStack Query is fetch implementation agnostic, I don't think it's concerned with anything like this. You can call start and done functions imperatively yourself, or, if you need actual request progress I think you'd need to use the XMLHttpRequest API (or a wrapper around it) as the Fetch API doesn't expose anything to do with request progress as far as I'm aware.
See: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#monitoring_progress
stormy-goldOP•3y ago
I think you are correct. I do not need to call these methods inside query lib,,, better to do that at fetch client level (whether it being axios or custom wrapper for fetch).