Skip to content

Commit cf8c160

Browse files
authored
docs: Update manual cancellation section to refer to QueryClient instead of QueryCache. (TanStack#1508)
1 parent 6eea150 commit cf8c160

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/src/pages/guides/query-cancellation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const query = useQuery('todos', () => {
5858

5959
## Manual Cancellation
6060

61-
You might want to cancel a query manually. For example, if the request takes a long time to finish, you can allow the user to click a cancel button to stop the request. To do this, you just need to call `cache.cancelQueries(key)`. If `promise.cancel` is available, React Query will cancel the request.
61+
You might want to cancel a query manually. For example, if the request takes a long time to finish, you can allow the user to click a cancel button to stop the request. To do this, you just need to call `queryClient.cancelQueries(key)`. If `promise.cancel` is available, React Query will cancel the request.
6262

6363
```js
6464
const [queryKey] = useState('todos')
@@ -78,12 +78,12 @@ const query = useQuery(queryKey, () => {
7878
return promise
7979
})
8080

81-
const cache = useQueryCache();
81+
const queryClient = useQueryClient();
8282

8383
return (
8484
<button onClick={(e) => {
8585
e.preventDefault();
86-
cache.cancelQueries(queryKey);
86+
queryClient.cancelQueries(queryKey);
8787
}}>Cancel</button>
8888
)
8989
```

0 commit comments

Comments
 (0)