TanStackT
TanStack11mo ago
12 replies
popular-magenta

how to "pause" queries globally?

I am currently using nextjs page router with react and I am looking for a way to pause all queries on the current page. Below is the use case:

1) I have 10+ queries on the page that is dependent on a location_id param as the query key
2) A user can switch user by clicking on a button on the page which triggers a mutation POST call that updates the location_id in the database and then routes the user to a different page after the mutation completes.

The problem I am running into is the location_id value changes before the routing completes and the 10+ queries on the page are now fetching for new data even though those 90% of those queries won't be used once the user is navigated away from the page after the location_id value changes.

I was wondering what would be the best way to handle this type of scenario. Thank you!
Was this page helpful?