Replies: 1 comment 4 replies
-
@githorse - I've created an example here for you: https://stackblitz.com/edit/stackblitz-starters-5vjibp?description=React%20%20%20TypeScript%20starter%20project&file=src%2Findex.tsx,src%2FApp.tsx&title=React%20Starter You can see the difference if you comment out Feel free to discuss further PS: This doesn't exactly cancel similar queries, but does cancel old queries in the component |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Say I want to show a month's worth of posts at a time. I have a datepicker widget on my screen that the user uses to select the month. My API looks like this:
I can use
useQuery
like so:But now I have some arrow buttons (⬅️ ➡️) that allow the user to rapidly scroll through the different months. If she clicks rapidly on ⬅️, I'll make a series of fetches:
The first two fetches are not helpful as the user doesn't care about that date range -- she just scrolled past it. I don't want to waste any cycles on that data when it arrives.
What I would like to happen is to be able to say to
useQuery
, "cancel any in-progress/posts
request if you see a different/posts
request".What's the best way to achieve this effect? (I'm not sure if this is a feature request or perhaps just a pattern I'm missing here.)
Beta Was this translation helpful? Give feedback.
All reactions