Skip to content

Commit 41b79fd

Browse files
committed
Merge remote-tracking branch 'upstream/main' into refactor/resolveValueOrFunction
2 parents 6fff343 + 7c464e3 commit 41b79fd

File tree

131 files changed

+2407
-474
lines changed

Some content is hidden

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

131 files changed

+2407
-474
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ jobs:
6565
run: |
6666
echo "COMMIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}" >> $GITHUB_ENV
6767
- name: Preview Bundle Size
68-
uses: marocchino/sticky-pull-request-comment@28d58c4b5a5eae3bbe45348c3990dcbc2ffcdc69
68+
uses: marocchino/sticky-pull-request-comment@9c40848920de7cd32a71773ba792d8b04f03bf7a
6969
with:
7070
message: |
7171
Sizes for commit ${{ env.COMMIT_SHA }}:
7272
| Branch | Bundle Size |
7373
|--------|--------|
74-
| Main | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.0/jsx-runtime?target=es2022%22,%22react@^19.1.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.0/jsx-runtime?target=es2022%22,%22react@%5E19.1.0?target=es2022%22%5D%7D%7D) |
75-
| This PR | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.0/jsx-runtime?target=es2022%22,%22react@^19.1.0?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.0/jsx-runtime?target=es2022%22,%22react@%5E19.1.0?target=es2022%22%5D%7D%7D) |
74+
| Main | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.1/jsx-runtime?target=es2022%22,%22react@^19.1.1?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/@tanstack/react-query/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.1/jsx-runtime?target=es2022%22,%22react@%5E19.1.1?target=es2022%22%5D%7D%7D) |
75+
| This PR | [![](https://deno.bundlejs.com/badge?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config={%22esbuild%22:{%22external%22:[%22react@^19.1.1/jsx-runtime?target=es2022%22,%22react@^19.1.1?target=es2022%22]}}&badge=detailed)](https://bundlejs.com/?q=https://esm.sh/pr/@tanstack/react-query@${{ env.COMMIT_SHA }}/es2022/react-query.mjs&config=%7B%22esbuild%22:%7B%22external%22:%5B%22react@%5E19.1.1/jsx-runtime?target=es2022%22,%22react@%5E19.1.1?target=es2022%22%5D%7D%7D) |
7676
continue-on-error: true

docs/framework/angular/devtools.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ id: devtools
33
title: Devtools
44
---
55

6-
> For Google Chrome users: A third-party Chrome extension is available for debugging TanStack Query directly in Chrome DevTools. This provides the same functionality as the framework-specific devtools packages. Check it out here: [TanStack Query DevTools](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
6+
> For Chrome, Firefox, and Edge users: Third-party browser extensions are available for debugging TanStack Query directly in browser DevTools. These provide the same functionality as the framework-specific devtools packages:
7+
>
8+
> - <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Chrome](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
9+
> - <img alt="Firefox logo" src="https://upload.wikimedia.org/wikipedia/commons/a/a0/Firefox_logo%2C_2019.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Firefox](https://addons.mozilla.org/en-US/firefox/addon/tanstack-query-devtools/)
10+
> - <img alt="Edge logo" src="https://upload.wikimedia.org/wikipedia/commons/9/98/Microsoft_Edge_logo_%282019%29.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
711
812
## Enable devtools
913

docs/framework/angular/typescript.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ import '@tanstack/angular-query-experimental'
153153

154154
declare module '@tanstack/angular-query-experimental' {
155155
interface Register {
156-
defaultError: AxiosError
156+
// Use unknown so call sites must narrow explicitly.
157+
defaultError: unknown
157158
}
158159
}
159160

@@ -164,7 +165,7 @@ const query = injectQuery(() => ({
164165

165166
computed(() => {
166167
const error = query.error()
167-
// ^? error: AxiosError | null
168+
// ^? error: unknown | null
168169
})
169170
```
170171

docs/framework/react/community/community-projects.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,28 @@ A family of libraries for building building browser and gRPC-compatible HTTP API
3131

3232
Link: https://connectrpc.com/docs
3333

34-
## DevTools Chrome Extension
34+
## DevTools Browser Extensions
3535

36-
A Chrome browser extension that provides devtools for TanStack Query, allowing you to inspect and debug queries, mutations, and cache state directly in Chrome DevTools.
36+
Browser extensions for Chrome, Firefox, and Edge that provide devtools for TanStack Query, allowing you to inspect and debug queries, mutations, and cache state directly in browser DevTools.
3737

38-
Link: https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai
38+
Links:
39+
40+
- <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Chrome](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
41+
- <img alt="Firefox logo" src="https://upload.wikimedia.org/wikipedia/commons/a/a0/Firefox_logo%2C_2019.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Firefox](https://addons.mozilla.org/en-US/firefox/addon/tanstack-query-devtools/)
42+
- <img alt="Edge logo" src="https://upload.wikimedia.org/wikipedia/commons/9/98/Microsoft_Edge_logo_%282019%29.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
3943

4044
## GraphQL Code Generator
4145

4246
Generate React Query hooks from your GraphQL schema
4347

4448
Link: https://the-guild.dev/graphql/codegen
4549

50+
## Hey API
51+
52+
The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.
53+
54+
Link: https://heyapi.dev/openapi-ts/plugins/tanstack-query
55+
4656
## Http-wizard
4757

4858
End-to-end type-safe Fastify API with typeScript magic ✨
@@ -98,6 +108,12 @@ A 2KB min, typesafe fetch wrapper that uses static TypeScript type inference and
98108

99109
Link: https://openapi-ts.dev/openapi-react-query/
100110

111+
## oRPC
112+
113+
Easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards.
114+
115+
Link: https://orpc.unnoq.com/docs/integrations/tanstack-query
116+
101117
## Orval
102118

103119
Generate TypeScript client from OpenAPI specifications

docs/framework/react/community/tkdodos-blog.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,47 @@ TanStack Query maintainer [TkDodo](https://bsky.app/profile/tkdodo.eu) has a ser
8484
## [#19: Type-safe React Query](https://tkdodo.eu/blog/type-safe-react-query)
8585

8686
> There's a big difference between "having types" and "being type-safe". This article tries to outline those differences and shows how you can get the best possible type-safety when using React Query together with TypeScript [Read more...](https://tkdodo.eu/blog/type-safe-react-query)
87+
88+
## [#20: You Might Not Need React Query](https://tkdodo.eu/blog/you-might-not-need-react-query)
89+
90+
> If your application doesn’t rely on client-side data fetching, especially when using frameworks like Next.js or Remix with built-in server components, React Query may be unnecessary. That said, it still shines in hybrid use cases (like infinite scrolling or offline support) where its smart caching and revalidation can be invaluable. [Read more...](https://tkdodo.eu/blog/you-might-not-need-react-query)
91+
92+
## [#21: Thinking in React Query](https://tkdodo.eu/blog/thinking-in-react-query)
93+
94+
> React Query isn’t a data-fetching library - it's an async state manager designed to treat parameters as dependencies, optimize refetch behavior via `staleTime`, and encourage declarative patterns where `queryKey` drives cache and updates. A small shift in mindset can dramatically streamline how you use React Query. [Read more...](https://tkdodo.eu/blog/thinking-in-react-query)
95+
96+
## [#22: React Query and React Context](https://tkdodo.eu/blog/react-query-and-react-context)
97+
98+
> React Query lets components independently manage their own data, making them self-sufficient and resilient, but when shared data (like user info fetched higher up) is needed deeper in the tree, React Context can make that implicit dependency explicit and safer. [Read more...](https://tkdodo.eu/blog/react-query-and-react-context)
99+
100+
## [#23: Why You Want React Query](https://tkdodo.eu/blog/why-you-want-react-query)
101+
102+
> While fetching data with `fetch` inside `useEffect` may seem simple, it quickly gets tangled with bugs like race conditions, missing loading states, stale data, and Strict Mode quirks—making async state management far more complex than it appears. [Read more...](https://tkdodo.eu/blog/why-you-want-react-query)
103+
104+
## [#24: The Query Options API](https://tkdodo.eu/blog/the-query-options-api)
105+
106+
> React Query v5 introduces a unified "Query Options" API - where all functions like `useQuery`, `invalidateQueries`, and imperative calls accept a single object - simplifying the interface and making reuse across different query contexts much easier while at the same time improving type-safety. [Read more...](https://tkdodo.eu/blog/the-query-options-api)
107+
108+
## [#25: Automatic Query Invalidation after Mutations](https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations)
109+
110+
> React Query doesn’t automatically tie mutations to queries - but you can leverage "global cache callbacks" in a central `MutationCache` to define shared behaviors like invalidating queries on every mutation. [Read more...](https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations)
111+
112+
## [#26: How Infinite Queries work](https://tkdodo.eu/blog/how-infinite-queries-work)
113+
114+
> This blog post is a deep dive into how Infinite Queries are designed and work under the hood. Interestingly, there is no distinct InfiniteQuery representation - just a different "behaviour" attached to regular Queries. [Read more...](https://tkdodo.eu/blog/how-infinite-queries-work)
115+
116+
## [#27: React Query API Design - Lessons Learned](https://tkdodo.eu/blog/react-query-api-design-lessons-learned)
117+
118+
> In this talk, Dominik walks us through some of the API design choices that were made in React Query to get to its arguably good developer experience. You'll hear stories about things that went well, but also about tradeoffs and mistakes that were made, and what lessons we can all learn from those. [Read more...](https://tkdodo.eu/blog/react-query-api-design-lessons-learned)
119+
120+
## [#28: React Query - The Bad Parts](https://tkdodo.eu/blog/react-query-the-bad-parts)
121+
122+
> In this talk, Dominik explores the less favorable aspects of React Query and situations where it may not be the best fit. No library is perfect; every choice involves trade-offs. By the end of this talk, you'll have a better understanding of React Query's limitations and why it remains a compelling choice despite them. [Read more...](https://tkdodo.eu/blog/react-query-the-bad-parts)
123+
124+
## [#29: Concurrent Optimistic Updates in React Query](https://tkdodo.eu/blog/concurrent-optimistic-updates-in-react-query)
125+
126+
> Optimistic updates in React Query can cause race conditions when multiple mutations run at once, leading to inconsistent UI states. Cancelling in-flight queries helps, but overlapping invalidations may still overwrite newer updates. [Read more...](https://tkdodo.eu/blog/concurrent-optimistic-updates-in-react-query)
127+
128+
## [#30: React Query Selectors, Supercharged](https://tkdodo.eu/blog/react-query-selectors-supercharged)
129+
130+
> React Query’s `select` option enables components to subscribe only to the specific part of a query’s data they care about - so updating one field won’t cause unrelated UI to re-render unnecessarily. This fine-grained approach keeps full responses in the cache while optimizing component updates for performance. [Read more...](https://tkdodo.eu/blog/react-query-selectors-supercharged)

docs/framework/react/devtools.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Wave your hands in the air and shout hooray because React Query comes with dedic
77

88
When you begin your React Query journey, you'll want these devtools by your side. They help visualize all the inner workings of React Query and will likely save you hours of debugging if you find yourself in a pinch!
99

10-
> For Google Chrome users: A third-party Chrome extension is available for debugging TanStack Query directly in Chrome DevTools. This provides the same functionality as the framework-specific devtools packages. Check it out here: [TanStack Query DevTools](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
10+
> For Chrome, Firefox, and Edge users: Third-party browser extensions are available for debugging TanStack Query directly in browser DevTools. These provide the same functionality as the framework-specific devtools packages:
11+
>
12+
> - <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Chrome](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
13+
> - <img alt="Firefox logo" src="https://upload.wikimedia.org/wikipedia/commons/a/a0/Firefox_logo%2C_2019.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Firefox](https://addons.mozilla.org/en-US/firefox/addon/tanstack-query-devtools/)
14+
> - <img alt="Edge logo" src="https://upload.wikimedia.org/wikipedia/commons/9/98/Microsoft_Edge_logo_%282019%29.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
1115
1216
> For React Native users: A third-party native macOS app is available for debugging React Query in ANY js-based application. Monitor queries across devices in real-time. Check it out here: [rn-better-dev-tools](https://github.com/LovesWorking/rn-better-dev-tools)
1317

docs/framework/react/guides/advanced-ssr.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,3 +621,11 @@ If you value DX/iteration/shipping speed with low code complexity over performan
621621
Server Components and streaming are still fairly new concepts and we are still figuring out how React Query fits in and what improvements we can make to the API. We welcome suggestions, feedback and bug reports!
622622

623623
Similarly, it would be impossible to teach all the intricacies of this new paradigm all in one guide, on the first try. If you are missing some piece of information here or have suggestions on how to improve this content, also get in touch, or even better, click the "Edit on GitHub" button below and help us out.
624+
625+
[//]: # 'Materials'
626+
627+
## Further reading
628+
629+
To understand if your application can benefit from React Query when also using Server Components, have a look at [You Might Not Need React Query](../../community/tkdodos-blog.md#20-you-might-not-need-react-query) from the Community Resources.
630+
631+
[//]: # 'Materials'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ Have a look at the following articles from our Community Resources for further e
4444

4545
- [Practical React Query](../../community/tkdodos-blog.md#1-practical-react-query)
4646
- [React Query as a State Manager](../../community/tkdodos-blog.md#10-react-query-as-a-state-manager)
47+
- [Thinking in React Query](../../community/tkdodos-blog.md#21-thinking-in-react-query)
4748

4849
[//]: # 'Materials'

docs/framework/react/guides/infinite-queries.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,11 @@ return useInfiniteQuery({
257257
```
258258

259259
[//]: # 'Example9'
260+
[//]: # 'Materials'
261+
262+
## Further reading
263+
264+
To get a better understanding of how Infinite Queries work under the hood, read [How Infinite Queries work](../../community/tkdodos-blog.md#26-how-infinite-queries-work) from
265+
the Community Resources.
266+
267+
[//]: # 'Materials'

docs/framework/react/guides/invalidations-from-mutations.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,32 @@ const queryClient = useQueryClient()
2727
// When this mutation succeeds, invalidate any queries with the `todos` or `reminders` query key
2828
const mutation = useMutation({
2929
mutationFn: addTodo,
30-
onSuccess: () => {
31-
queryClient.invalidateQueries({ queryKey: ['todos'] })
32-
queryClient.invalidateQueries({ queryKey: ['reminders'] })
30+
onSuccess: async () => {
31+
// If you're invalidating a single query
32+
await queryClient.invalidateQueries({ queryKey: ['todos'] })
33+
34+
// If you're invalidating multiple queries
35+
await Promise.all([
36+
queryClient.invalidateQueries({ queryKey: ['todos'] }),
37+
queryClient.invalidateQueries({ queryKey: ['reminders'] }),
38+
])
3339
},
3440
})
3541
```
3642

3743
[//]: # 'Example2'
3844

45+
Returning a Promise on `onSuccess` makes sure the data is updated before the mutation is entirely complete (i.e., isPending is true until onSuccess is fulfilled)
46+
47+
[//]: # 'Example2'
48+
3949
You can wire up your invalidations to happen using any of the callbacks available in the [`useMutation` hook](../mutations.md)
50+
51+
[//]: # 'Materials'
52+
53+
## Further reading
54+
55+
For a technique to automatically invalidate Queries after Mutations, have a look at [Automatic Query Invalidation after Mutations](../../community/tkdodos-blog.md#25-automatic-query-invalidation-after-mutations) from
56+
the Community Resources.
57+
58+
[//]: # 'Materials'

0 commit comments

Comments
 (0)