Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/pages/guides/query-cancellation.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const query = useQuery('todos', () => {

## Manual Cancellation

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.
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.

```js
const [queryKey] = useState('todos')
Expand All @@ -78,12 +78,12 @@ const query = useQuery(queryKey, () => {
return promise
})

const cache = useQueryCache();
const queryClient = useQueryClient();

return (
<button onClick={(e) => {
e.preventDefault();
cache.cancelQueries(queryKey);
queryClient.cancelQueries(queryKey);
}}>Cancel</button>
)
```