Skip to content

Commit 2164530

Browse files
feat(types): Add optional cancelRefetch field to ResultOptions interface (#1663)
* feat(types): Add optional cancelRefetch field to ResultOptions interface * feat(docs): Add cancelRefetch documentation for the refetch function
1 parent 397d8b7 commit 2164530

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/src/pages/reference/useQuery.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ const result = useQuery({
208208
- The failure count for the query.
209209
- Incremented every time the query fails.
210210
- Reset to `0` when the query succeeds.
211-
- `refetch: (options: { throwOnError: boolean }) => Promise<UseQueryResult>`
211+
- `refetch: (options: { throwOnError: boolean, cancelRefetch: boolean }) => Promise<UseQueryResult>`
212212
- A function to manually refetch the query.
213213
- If the query errors, the error will only be logged. If you want an error to be thrown, pass the `throwOnError: true` option
214+
- If `cancelRefetch` is `true`, then the current request will be cancelled before a new request is made
214215
- `remove: () => void`
215216
- A function to remove the query from the cache.

src/core/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ export interface ResultOptions {
216216
throwOnError?: boolean
217217
}
218218

219-
export interface RefetchOptions extends ResultOptions {}
219+
export interface RefetchOptions extends ResultOptions {
220+
cancelRefetch?: boolean;
221+
}
220222

221223
export interface InvalidateQueryFilters extends QueryFilters {
222224
refetchActive?: boolean

0 commit comments

Comments
 (0)