-
I'm not 100% sure if this already possible, but couldn't find anything related in the docs or in Discussions here on GitHub. I have a long list, which is filterable and also supports pagination. I'm querying with useQuery(
[QueryKey.Components, filterInput],
({ queryKey: [key, input] }: { queryKey: [QueryKey, FilterInput] }) => apiService.getComponents(input),
{
...queryOptions,
enabled: false,
keepPreviousData: true,
}
); I want to cancel all previous active queries when they are not resolved yet (still fetching) and the user already triggered a new query. E.g. when clicking multiple times on the next page button in a short period of time. Is it possible to use queryClient.cancelQueries([QueryKey.Components], { fetching: true }); Thanks in advance for any feedback and help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
yes, this is the exact syntax that you need. |
Beta Was this translation helpful? Give feedback.
yes, this is the exact syntax that you need.
cancelQueries
accepts a query filter, so you can do that. But just doingqueryClient.cancelQueries([QueryKey.Components])
should be enough as well, because a query that is not fetching cannot be cancelled I guess :)