Skip to content

Commit 1fe93b6

Browse files
authored
Merge branch 'main' into test/react-query-hydration-boundary-invalid-state-handling
2 parents 4604258 + aec19c9 commit 1fe93b6

File tree

82 files changed

+213
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+213
-171
lines changed

docs/framework/react/guides/query-cancellation.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ return (
188188

189189
[//]: # 'Example7'
190190

191+
## `Cancel Options`
192+
193+
Cancel options are used to control the behavior of query cancellation operations.
194+
195+
```tsx
196+
// Cancel specific queries silently
197+
await queryClient.cancelQueries({ queryKey: ['posts'] }, { silent: true })
198+
```
199+
200+
A cancel options object supports the following properties:
201+
202+
- `silent?: boolean`
203+
- When set to `true`, suppresses propagation of `CancelledError` to observers (e.g., `onError` callbacks) and related notifications, and returns the retry promise instead of rejecting.
204+
- Defaults to `false`
205+
- `revert?: boolean`
206+
- When set to `true`, restores the query’s state (data and status) from immediately before the in-flight fetch, sets `fetchStatus` back to `idle`, and only throws if there was no prior data.
207+
- Defaults to `true`
208+
191209
## Limitations
192210

193211
Cancellation does not work when working with `Suspense` hooks: `useSuspenseQuery`, `useSuspenseQueries` and `useSuspenseInfiniteQuery`.

docs/framework/react/react-native.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ useEffect(() => {
7474
## Refresh on Screen focus
7575

7676
In some situations, you may want to refetch the query when a React Native Screen is focused again.
77-
This custom hook will call the provided `refetch` function when the screen is focused again.
77+
This custom hook will refetch **all active stale queries** when the screen is focused again.
7878

7979
```tsx
8080
import React from 'react'
8181
import { useFocusEffect } from '@react-navigation/native'
82+
import { useQueryClient } from '@tanstack/react-query'
8283

83-
export function useRefreshOnFocus<T>(refetch: () => Promise<T>) {
84+
export function useRefreshOnFocus() {
85+
const queryClient = useQueryClient()
8486
const firstTimeRef = React.useRef(true)
8587

8688
useFocusEffect(
@@ -90,13 +92,18 @@ export function useRefreshOnFocus<T>(refetch: () => Promise<T>) {
9092
return
9193
}
9294

93-
refetch()
94-
}, [refetch]),
95+
// refetch all stale active queries
96+
queryClient.refetchQueries({
97+
queryKey: ['posts'],
98+
stale: true,
99+
type: 'active',
100+
})
101+
}, [queryClient]),
95102
)
96103
}
97104
```
98105

99-
In the above code, `refetch` is skipped the first time because `useFocusEffect` calls our callback on mount in addition to screen focus.
106+
In the above code, the first focus (when the screen is initially mounted) is skipped because `useFocusEffect` calls our callback on mount in addition to screen focus.
100107

101108
## Disable queries on out of focus screens
102109

docs/reference/QueryClient.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,16 @@ The `cancelQueries` method can be used to cancel outgoing queries based on their
403403
This is most useful when performing optimistic updates since you will likely need to cancel any outgoing query refetches so they don't clobber your optimistic update when they resolve.
404404

405405
```tsx
406-
await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })
406+
await queryClient.cancelQueries(
407+
{ queryKey: ['posts'], exact: true },
408+
{ silent: true },
409+
)
407410
```
408411

409412
**Options**
410413

411414
- `filters?: QueryFilters`: [Query Filters](../../framework/react/guides/filters.md#query-filters)
415+
- `cancelOptions?: CancelOptions`: [Cancel Options](../../framework/react/guides/query-cancellation.md#cancel-options)
412416

413417
**Returns**
414418

examples/angular/auto-refetching/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@angular/compiler": "^20.0.0",
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
16-
"@tanstack/angular-query-experimental": "^5.85.6",
16+
"@tanstack/angular-query-experimental": "^5.85.7",
1717
"rxjs": "^7.8.2",
1818
"tslib": "^2.8.1",
1919
"zone.js": "0.15.0"

examples/angular/basic-persister/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"@angular/compiler": "^20.0.0",
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
16-
"@tanstack/angular-query-experimental": "^5.85.6",
16+
"@tanstack/angular-query-experimental": "^5.85.7",
1717
"@tanstack/angular-query-persist-client": "^5.62.7",
18-
"@tanstack/query-async-storage-persister": "^5.85.6",
18+
"@tanstack/query-async-storage-persister": "^5.85.7",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@angular/compiler": "^20.0.0",
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
16-
"@tanstack/angular-query-experimental": "^5.85.6",
16+
"@tanstack/angular-query-experimental": "^5.85.7",
1717
"rxjs": "^7.8.2",
1818
"tslib": "^2.8.1",
1919
"zone.js": "0.15.0"

examples/angular/devtools-panel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
1616
"@angular/router": "^20.0.0",
17-
"@tanstack/angular-query-devtools-experimental": "^5.85.6",
18-
"@tanstack/angular-query-experimental": "^5.85.6",
17+
"@tanstack/angular-query-devtools-experimental": "^5.85.7",
18+
"@tanstack/angular-query-experimental": "^5.85.7",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/infinite-query-with-max-pages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@angular/compiler": "^20.0.0",
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
16-
"@tanstack/angular-query-experimental": "^5.85.6",
16+
"@tanstack/angular-query-experimental": "^5.85.7",
1717
"rxjs": "^7.8.2",
1818
"tslib": "^2.8.1",
1919
"zone.js": "0.15.0"

examples/angular/optimistic-updates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^20.0.0",
1515
"@angular/forms": "^20.0.0",
1616
"@angular/platform-browser": "^20.0.0",
17-
"@tanstack/angular-query-experimental": "^5.85.6",
17+
"@tanstack/angular-query-experimental": "^5.85.7",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

examples/angular/pagination/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@angular/compiler": "^20.0.0",
1414
"@angular/core": "^20.0.0",
1515
"@angular/platform-browser": "^20.0.0",
16-
"@tanstack/angular-query-experimental": "^5.85.6",
16+
"@tanstack/angular-query-experimental": "^5.85.7",
1717
"rxjs": "^7.8.2",
1818
"tslib": "^2.8.1",
1919
"zone.js": "0.15.0"

0 commit comments

Comments
 (0)