Cancel paused queries on component unmount
Use case : I go to a screen A while offline and then come back to previous screen B. When I come online I don't want fetch for screen A to happen in background.
Basically, I want to cancel a query if the component in which it is present is unmounted.
Passing
signal in axios.get to cancel query works but only for idle queries. But for paused query it doesn't stop network request.
Is there a way to even cancel paused queries ?
Note : This post has been edited.2 Replies
conscious-sapphire•3y ago
Are you using v3 or v4? There have been some changes in how the library handles offline networks, as described here: https://tkdodo.eu/blog/offline-react-query#1-no-data-in-the-cache
Also, when you're going to screen A while being offline, is your query function still called or does the query goes to the "paused" state?
Offline React Query
A glimpse at what v4 will bring for offline queries
optimistic-goldOP•3y ago
I'm using v4.
When I am in offline mode query function is not called and my query's fetchState is
paused.
Also, I am testing on react native app for ios.