Skip to content

Commit d2e9d3e

Browse files
authored
docs(query-cancellation): remove more references to old cancel fn (#4631)
Apparently these were missed in a1050eb. It is confusing because the [Migration to v4 guide](https://tanstack.com/query/v4/docs/guides/migrating-to-react-query-4#the-cancel-method-on-promises-is-no-longer-supported) states that the `cancel` property in promises is no longer supported, but the docs for Query Cancellation seem to imply that it is. I assume that it is not supported anymore based on the commit linked above, the migration guide and my own testing. If that is indeed the case, let's clean this up.
1 parent 2a370ab commit d2e9d3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/guides/query-cancellation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The `AbortController` API is available in [most runtime environments](https://de
1111

1212
By default, queries that unmount or become unused before their promises are resolved are _not_ cancelled. This means that after the promise has resolved, the resulting data will be available in the cache. This is helpful if you've started receiving a query, but then unmount the component before it finishes. If you mount the component again and the query has not been garbage collected yet, data will be available.
1313

14-
However, if you consume the `AbortSignal` or attach a `cancel` function to your Promise, the Promise will be cancelled (e.g. aborting the fetch) and therefore, also the Query must be cancelled. Cancelling the query will result in its state being _reverted_ to its previous state.
14+
However, if you consume the `AbortSignal`, the Promise will be cancelled (e.g. aborting the fetch) and therefore, also the Query must be cancelled. Cancelling the query will result in its state being _reverted_ to its previous state.
1515

1616
## Using `fetch`
1717

@@ -137,7 +137,7 @@ const query = useQuery({
137137

138138
## Manual Cancellation
139139

140-
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({ queryKey })`, which will cancel the query and revert it back to its previous state. If `promise.cancel` is available, or you have consumed the `signal` passed to the query function, React Query will additionally also cancel the Promise.
140+
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({ queryKey })`, which will cancel the query and revert it back to its previous state. If you have consumed the `signal` passed to the query function, React Query will additionally also cancel the Promise.
141141

142142
```tsx
143143
const query = useQuery({

0 commit comments

Comments
 (0)