Skip to content

Commit 588d54c

Browse files
authored
Add cancelQueries types and missing links in docs (#494)
* fix(Types): add queryCache.cancelQueries types * docs: add missing links to cancelQueries
1 parent f671595 commit 588d54c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ This library is being built and maintained by me, @tannerlinsley and I am always
250250
- [`queryCache.getQueryData`](#querycachegetquerydata)
251251
- [`queryCache.setQueryData`](#querycachesetquerydata)
252252
- [`queryCache.refetchQueries`](#querycacherefetchqueries)
253+
- [`queryCache.cancelQueries`](#querycachecancelqueries)
253254
- [`queryCache.removeQueries`](#querycacheremovequeries)
254255
- [`queryCache.getQuery`](#querycachegetquery)
255256
- [`queryCache.getQueries`](#querycachegetqueries)
@@ -2236,6 +2237,7 @@ The `queryCache` instance is the backbone of React Query that manages all of the
22362237
- [`getQueryData`](#querycachegetquerydata)
22372238
- [`setQueryData`](#querycachesetquerydata)
22382239
- [`refetchQueries`](#querycacherefetchqueries)
2240+
- [`cancelQueries`](#querycachecancelqueries)
22392241
- [`removeQueries`](#querycacheremovequeries)
22402242
- [`getQueries`](#querycachegetqueries)
22412243
- [`getQuery`](#querycachegetquery)
@@ -2361,7 +2363,7 @@ const queries = queryCache.refetchQueries(inclusiveQueryKeyOrPredicateFn, {
23612363
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
23622364
- The `exact` option has no effect with using a function
23632365
- `exact: Boolean`
2364-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2366+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
23652367
- `throwOnError: Boolean`
23662368
- When set to `true`, this function will throw if any of the query refetch tasks fail.
23672369
- `force: Boolean`
@@ -2394,7 +2396,7 @@ const queries = queryCache.cancelQueries(queryKeyOrPredicateFn, {
23942396
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
23952397
- The `exact` option has no effect with using a function
23962398
- `exact: Boolean`
2397-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2399+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
23982400

23992401
### Returns
24002402

@@ -2421,7 +2423,7 @@ const queries = queryCache.removeQueries(queryKeyOrPredicateFn, {
24212423
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
24222424
- The `exact` option has no effect with using a function
24232425
- `exact: Boolean`
2424-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2426+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
24252427

24262428
### Returns
24272429

types/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,13 @@ export interface QueryCache {
692692
): Promise<void>
693693
getQuery(queryKey: AnyQueryKey): CachedQuery<unknown> | undefined
694694
getQueries(queryKey: AnyQueryKey): Array<CachedQuery<unknown>>
695+
cancelQueries(
696+
queryKeyOrPredicateFn:
697+
| AnyQueryKey
698+
| string
699+
| ((query: CachedQuery<unknown>) => boolean),
700+
{ exact }?: { exact?: boolean }
701+
): void
695702
isFetching: number
696703
subscribe(callback: (queryCache: QueryCache) => void): () => void
697704
clear(): Array<CachedQuery<unknown>>

0 commit comments

Comments
 (0)