Skip to content

Commit d5e489a

Browse files
authored
Merge branch 'main' into fix/add-thenable-reject-args
2 parents f3861c2 + 7cf6ef5 commit d5e489a

File tree

105 files changed

+1419
-874
lines changed

Some content is hidden

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

105 files changed

+1419
-874
lines changed

.github/renovate.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@types/node",
2121
"@types/react",
2222
"@types/react-dom",
23-
"eslint-plugin-react-compiler",
2423
"node",
2524
"react",
2625
"react-dom",

docs/framework/react/guides/important-defaults.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ Out of the box, TanStack Query is configured with **aggressive but sane** defaul
99

1010
> To change this behavior, you can configure your queries both globally and per-query using the `staleTime` option. Specifying a longer `staleTime` means queries will not refetch their data as often
1111
12+
- A Query that has a `staleTime` set is considered **fresh** until that `staleTime` has elapsed.
13+
14+
- set `staleTime` to e.g. `2 * 60 * 1000` to make sure data is read from the cache, without triggering any kinds of refetches, for 2 minutes, or until the Query is [invalidated manually](./query-invalidation.md).
15+
- set `staleTime` to `Infinity` to never trigger a refetch until the Query is [invalidated manually](./query-invalidation.md).
16+
- set `staleTime` to `'static'` to **never** trigger a refetch, even if the Query is [invalidated manually](./query-invalidation.md).
17+
1218
- Stale queries are refetched automatically in the background when:
1319
- New instances of the query mount
1420
- The window is refocused
1521
- The network is reconnected
16-
- The query is optionally configured with a refetch interval
1722

18-
> To change this functionality, you can use options like `refetchOnMount`, `refetchOnWindowFocus`, `refetchOnReconnect` and `refetchInterval`.
23+
> Setting `staleTime` is the recommended way to avoid excessive refetches, but you can also customize the points in time for refetches by setting options like `refetchOnMount`, `refetchOnWindowFocus` and `refetchOnReconnect`.
24+
25+
- Queries can optionally be configured with a `refetchInterval` to trigger refetches periodically, which is independent of the `staleTime` setting.
1926

2027
- Query results that have no more active instances of `useQuery`, `useInfiniteQuery` or query observers are labeled as "inactive" and remain in the cache in case they are used again at a later time.
2128
- By default, "inactive" queries are garbage collected after **5 minutes**.

docs/framework/react/reference/useQuery.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ const {
9090
- This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds.
9191
- A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff.
9292
- A function like `attempt => attempt * 1000` applies linear backoff.
93-
- `staleTime: number | ((query: Query) => number)`
93+
- `staleTime: number | 'static' ((query: Query) => number | 'static')`
9494
- Optional
9595
- Defaults to `0`
9696
- The time in milliseconds after which data is considered stale. This value only applies to the hook it is defined on.
97-
- If set to `Infinity`, the data will never be considered stale
97+
- If set to `Infinity`, the data will not be considered stale unless manually invalidated
9898
- If set to a function, the function will be executed with the query to compute a `staleTime`.
99+
- If set to `'static'`, the data will never be considered stale
99100
- `gcTime: number | Infinity`
100101
- Defaults to `5 * 60 * 1000` (5 minutes) or `Infinity` during SSR
101102
- The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used.
@@ -116,21 +117,21 @@ const {
116117
- Defaults to `true`
117118
- If set to `true`, the query will refetch on mount if the data is stale.
118119
- If set to `false`, the query will not refetch on mount.
119-
- If set to `"always"`, the query will always refetch on mount.
120+
- If set to `"always"`, the query will always refetch on mount (except when `staleTime: 'static'` is used).
120121
- If set to a function, the function will be executed with the query to compute the value
121122
- `refetchOnWindowFocus: boolean | "always" | ((query: Query) => boolean | "always")`
122123
- Optional
123124
- Defaults to `true`
124125
- If set to `true`, the query will refetch on window focus if the data is stale.
125126
- If set to `false`, the query will not refetch on window focus.
126-
- If set to `"always"`, the query will always refetch on window focus.
127+
- If set to `"always"`, the query will always refetch on window focus (except when `staleTime: 'static'` is used).
127128
- If set to a function, the function will be executed with the query to compute the value
128129
- `refetchOnReconnect: boolean | "always" | ((query: Query) => boolean | "always")`
129130
- Optional
130131
- Defaults to `true`
131132
- If set to `true`, the query will refetch on reconnect if the data is stale.
132133
- If set to `false`, the query will not refetch on reconnect.
133-
- If set to `"always"`, the query will always refetch on reconnect.
134+
- If set to `"always"`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used).
134135
- If set to a function, the function will be executed with the query to compute the value
135136
- `notifyOnChangeProps: string[] | "all" | (() => string[] | "all" | undefined)`
136137
- Optional

docs/reference/QueryClient.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ The `invalidateQueries` method can be used to invalidate and refetch single or m
321321

322322
- If you **do not want active queries to refetch**, and simply be marked as invalid, you can use the `refetchType: 'none'` option.
323323
- If you **want inactive queries to refetch** as well, use the `refetchType: 'all'` option
324+
- For refetching, [queryClient.refetchQueries](#queryclientrefetchqueries) is called.
324325

325326
```tsx
326327
await queryClient.invalidateQueries(
@@ -390,6 +391,11 @@ await queryClient.refetchQueries({
390391

391392
This function returns a promise that will resolve when all of the queries are done being refetched. By default, it **will not** throw an error if any of those queries refetches fail, but this can be configured by setting the `throwOnError` option to `true`
392393

394+
**Notes**
395+
396+
- Queries that are "disabled" because they only have disabled Observers will never be refetched.
397+
- Queries that are "static" because they only have Observers with a Static StaleTime will never be refetched.
398+
393399
## `queryClient.cancelQueries`
394400

395401
The `cancelQueries` method can be used to cancel outgoing queries based on their query keys or any other functionally accessible property/state of the query.

examples/angular/auto-refetching/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@tanstack/angular-query-experimental": "^5.79.0",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"
2121
},
2222
"devDependencies": {
23-
"@angular/build": "^20.0.0-rc.2",
24-
"@angular/cli": "^20.0.0-rc.2",
25-
"@angular/compiler-cli": "^20.0.0-rc.0",
23+
"@angular/build": "^20.0.0",
24+
"@angular/cli": "^20.0.0",
25+
"@angular/compiler-cli": "^20.0.0",
2626
"typescript": "5.8.3"
2727
}
2828
}

examples/angular/basic-persister/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@tanstack/angular-query-experimental": "^5.79.0",
1818
"@tanstack/angular-query-persist-client": "^5.62.7",
19-
"@tanstack/query-sync-storage-persister": "^5.77.2",
19+
"@tanstack/query-sync-storage-persister": "^5.79.0",
2020
"rxjs": "^7.8.2",
2121
"tslib": "^2.8.1",
2222
"zone.js": "0.15.0"
2323
},
2424
"devDependencies": {
25-
"@angular/build": "^20.0.0-rc.2",
26-
"@angular/cli": "^20.0.0-rc.2",
27-
"@angular/compiler-cli": "^20.0.0-rc.0",
25+
"@angular/build": "^20.0.0",
26+
"@angular/cli": "^20.0.0",
27+
"@angular/compiler-cli": "^20.0.0",
2828
"typescript": "5.8.3"
2929
}
3030
}

examples/angular/basic/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@tanstack/angular-query-experimental": "^5.79.0",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"
2121
},
2222
"devDependencies": {
23-
"@angular/build": "^20.0.0-rc.2",
24-
"@angular/cli": "^20.0.0-rc.2",
25-
"@angular/compiler-cli": "^20.0.0-rc.0",
23+
"@angular/build": "^20.0.0",
24+
"@angular/cli": "^20.0.0",
25+
"@angular/compiler-cli": "^20.0.0",
2626
"typescript": "5.8.3"
2727
}
2828
}

examples/angular/devtools-panel/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@angular/router": "^20.0.0-rc.0",
18-
"@tanstack/angular-query-devtools-experimental": "^5.77.2",
19-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@angular/router": "^20.0.0",
18+
"@tanstack/angular-query-devtools-experimental": "^5.79.0",
19+
"@tanstack/angular-query-experimental": "^5.79.0",
2020
"rxjs": "^7.8.2",
2121
"tslib": "^2.8.1",
2222
"zone.js": "0.15.0"
2323
},
2424
"devDependencies": {
25-
"@angular/build": "^20.0.0-rc.2",
26-
"@angular/cli": "^20.0.0-rc.2",
27-
"@angular/compiler-cli": "^20.0.0-rc.0",
25+
"@angular/build": "^20.0.0",
26+
"@angular/cli": "^20.0.0",
27+
"@angular/compiler-cli": "^20.0.0",
2828
"typescript": "5.8.3"
2929
}
3030
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
"watch": "ng build --watch --configuration development"
1010
},
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@tanstack/angular-query-experimental": "^5.79.0",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"
2121
},
2222
"devDependencies": {
23-
"@angular/build": "^20.0.0-rc.2",
24-
"@angular/cli": "^20.0.0-rc.2",
25-
"@angular/compiler-cli": "^20.0.0-rc.0",
23+
"@angular/build": "^20.0.0",
24+
"@angular/cli": "^20.0.0",
25+
"@angular/compiler-cli": "^20.0.0",
2626
"typescript": "5.8.3"
2727
}
2828
}

examples/angular/optimistic-updates/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/forms": "^20.0.0-rc.0",
16-
"@angular/platform-browser": "^20.0.0-rc.0",
17-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
18-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/forms": "^20.0.0",
16+
"@angular/platform-browser": "^20.0.0",
17+
"@angular/platform-browser-dynamic": "^20.0.0",
18+
"@tanstack/angular-query-experimental": "^5.79.0",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"
2222
},
2323
"devDependencies": {
24-
"@angular/build": "^20.0.0-rc.2",
25-
"@angular/cli": "^20.0.0-rc.2",
26-
"@angular/compiler-cli": "^20.0.0-rc.0",
24+
"@angular/build": "^20.0.0",
25+
"@angular/cli": "^20.0.0",
26+
"@angular/compiler-cli": "^20.0.0",
2727
"typescript": "5.8.3"
2828
}
2929
}

examples/angular/pagination/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
"watch": "ng build --watch --configuration development"
1010
},
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@tanstack/angular-query-experimental": "^5.79.0",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"
2121
},
2222
"devDependencies": {
23-
"@angular/build": "^20.0.0-rc.2",
24-
"@angular/cli": "^20.0.0-rc.2",
25-
"@angular/compiler-cli": "^20.0.0-rc.0",
23+
"@angular/build": "^20.0.0",
24+
"@angular/cli": "^20.0.0",
25+
"@angular/compiler-cli": "^20.0.0",
2626
"typescript": "5.8.3"
2727
}
2828
}

examples/angular/query-options-from-a-service/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@angular/router": "^20.0.0-rc.0",
18-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@angular/router": "^20.0.0",
18+
"@tanstack/angular-query-experimental": "^5.79.0",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"
2222
},
2323
"devDependencies": {
24-
"@angular/build": "^20.0.0-rc.2",
25-
"@angular/cli": "^20.0.0-rc.2",
26-
"@angular/compiler-cli": "^20.0.0-rc.0",
24+
"@angular/build": "^20.0.0",
25+
"@angular/cli": "^20.0.0",
26+
"@angular/compiler-cli": "^20.0.0",
2727
"typescript": "5.8.3"
2828
}
2929
}

examples/angular/router/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
},
1010
"private": true,
1111
"dependencies": {
12-
"@angular/common": "^20.0.0-rc.0",
13-
"@angular/compiler": "^20.0.0-rc.0",
14-
"@angular/core": "^20.0.0-rc.0",
15-
"@angular/platform-browser": "^20.0.0-rc.0",
16-
"@angular/platform-browser-dynamic": "^20.0.0-rc.0",
17-
"@angular/router": "^20.0.0-rc.0",
18-
"@tanstack/angular-query-experimental": "^5.77.2",
12+
"@angular/common": "^20.0.0",
13+
"@angular/compiler": "^20.0.0",
14+
"@angular/core": "^20.0.0",
15+
"@angular/platform-browser": "^20.0.0",
16+
"@angular/platform-browser-dynamic": "^20.0.0",
17+
"@angular/router": "^20.0.0",
18+
"@tanstack/angular-query-experimental": "^5.79.0",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"
2222
},
2323
"devDependencies": {
24-
"@angular/build": "^20.0.0-rc.2",
25-
"@angular/cli": "^20.0.0-rc.2",
26-
"@angular/compiler-cli": "^20.0.0-rc.0",
24+
"@angular/build": "^20.0.0",
25+
"@angular/cli": "^20.0.0",
26+
"@angular/compiler-cli": "^20.0.0",
2727
"typescript": "5.8.3"
2828
}
2929
}

0 commit comments

Comments
 (0)