You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/react/community/tkdodos-blog.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: tkdodos-blog
3
3
title: TkDodo's Blog
4
4
---
5
5
6
-
TanStack Query maintainer [TkDodo](https://twitter.com/tkdodo) has a series of blog posts about using and working with the library. Some articles show general best practices, but most have an _opinionated_ point of view.
6
+
TanStack Query maintainer [TkDodo](https://bsky.app/profile/tkdodo.eu) has a series of blog posts about using and working with the library. Some articles show general best practices, but most have an _opinionated_ point of view.
Copy file name to clipboardExpand all lines: docs/framework/react/guides/advanced-ssr.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -530,7 +530,7 @@ export default function Posts() {
530
530
531
531
Now, your `getPosts` function can return e.g. `Temporal` datetime objects and the data will be serialized and deserialized on the client, assuming your transformer can serialize and deserialize those data types.
532
532
533
-
For more information, check out the [Next.js App with Prefetching Example](../../../../examples/react/nextjs-app-prefetching).
533
+
For more information, check out the [Next.js App with Prefetching Example](../examples/react/nextjs-app-prefetching).
534
534
535
535
## Experimental streaming without prefetching in Next.js
For more information, check out the [NextJs Suspense Streaming Example](../../../../examples/react/nextjs-suspense-streaming).
600
+
For more information, check out the [NextJs Suspense Streaming Example](../examples/react/nextjs-suspense-streaming).
601
601
602
602
The big upside is that you no longer need to prefetch queries manually to have SSR work, and it even still streams in the result! This gives you phenomenal DX and lower code complexity.
Copy file name to clipboardExpand all lines: docs/framework/react/guides/caching.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: caching
3
3
title: Caching Examples
4
4
---
5
5
6
-
> Please thoroughly read the [Important Defaults](./important-defaults) before reading this guide
6
+
> Please thoroughly read the [Important Defaults](./important-defaults.md) before reading this guide
7
7
8
8
## Basic Example
9
9
@@ -23,7 +23,7 @@ Let's assume we are using the default `gcTime` of **5 minutes** and the default
23
23
- A second instance of `useQuery({ queryKey: ['todos'], queryFn: fetchTodos })` mounts elsewhere.
24
24
- Since the cache already has data for the `['todos']` key from the first query, that data is immediately returned from the cache.
25
25
- The new instance triggers a new network request using its query function.
26
-
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../reference/useQuery) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
26
+
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../reference/useQuery.md) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
27
27
- When the request completes successfully, the cache's data under the `['todos']` key is updated with the new data, and both instances are updated with the new data.
28
28
- Both instances of the `useQuery({ queryKey: ['todos'], queryFn: fetchTodos })` query are unmounted and no longer in use.
29
29
- Since there are no more active instances of this query, a garbage collection timeout is set using `gcTime` to delete and garbage collect the query (defaults to **5 minutes**).
Dependent queries by definition constitutes a form of [request waterfall](../../../react/guides/request-waterfalls), which hurts performance. If we pretend both queries take the same amount of time, doing them serially instead of in parallel always takes twice as much time, which is especially hurtful when it happens on a client that has high latency. If you can, it's always better to restructure the backend APIs so that both queries can be fetched in parallel, though that might not always be practically feasible.
93
+
Dependent queries by definition constitutes a form of [request waterfall](./request-waterfalls.md), which hurts performance. If we pretend both queries take the same amount of time, doing them serially instead of in parallel always takes twice as much time, which is especially hurtful when it happens on a client that has high latency. If you can, it's always better to restructure the backend APIs so that both queries can be fetched in parallel, though that might not always be practically feasible.
94
94
95
95
In the example above, instead of first fetching `getUserByEmail` to be able to `getProjectsByUser`, introducing a new `getProjectsByUserEmail` query would flatten the waterfall.
Copy file name to clipboardExpand all lines: docs/framework/react/guides/initial-query-data.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ There are many ways to supply initial data for a query to the cache before you n
8
8
- Declaratively:
9
9
- Provide `initialData` to a query to prepopulate its cache if empty
10
10
- Imperatively:
11
-
-[Prefetch the data using `queryClient.prefetchQuery`](../../../react/guides/prefetching)
12
-
-[Manually place the data into the cache using `queryClient.setQueryData`](../../../react/guides/prefetching)
11
+
-[Prefetch the data using `queryClient.prefetchQuery`](./prefetching.md)
12
+
-[Manually place the data into the cache using `queryClient.setQueryData`](./prefetching.md)
13
13
14
14
## Using `initialData` to prepopulate a query
15
15
@@ -170,6 +170,6 @@ const result = useQuery({
170
170
171
171
## Further reading
172
172
173
-
For a comparison between `Initial Data` and `Placeholder Data`, have a look at the [Community Resources](../community/tkdodos-blog#9-placeholder-and-initial-data-in-react-query).
173
+
For a comparison between `Initial Data` and `Placeholder Data`, have a look at the [Community Resources](../community/tkdodos-blog.md#9-placeholder-and-initial-data-in-react-query).
Copy file name to clipboardExpand all lines: docs/framework/react/guides/migrating-to-react-query-3.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -103,8 +103,8 @@ try {
103
103
104
104
Together, these provide the same experience as before, but with added control to choose which component trees you want to reset. For more information, see:
Copy file name to clipboardExpand all lines: docs/framework/react/guides/migrating-to-react-query-4.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -58,9 +58,9 @@ Please note in the case of `TypeScript` you need to use `tsx` as the parser; oth
58
58
59
59
### Query Keys (and Mutation Keys) need to be an Array
60
60
61
-
In v3, Query and Mutation Keys could be a String or an Array. Internally, React Query has always worked with Array Keys only, and we've sometimes exposed this to consumers. For example, in the `queryFn`, you would always get the key as an Array to make working with [Default Query Functions](../default-query-function) easier.
61
+
In v3, Query and Mutation Keys could be a String or an Array. Internally, React Query has always worked with Array Keys only, and we've sometimes exposed this to consumers. For example, in the `queryFn`, you would always get the key as an Array to make working with [Default Query Functions](./default-query-function.md) easier.
62
62
63
-
However, we have not followed this concept through to all apis. For example, when using the `predicate` function on [Query Filters](../filters) you would get the raw Query Key. This makes it difficult to work with such functions if you use Query Keys that are mixed Arrays and Strings. The same was true when using global callbacks.
63
+
However, we have not followed this concept through to all apis. For example, when using the `predicate` function on [Query Filters](./filters.md) you would get the raw Query Key. This makes it difficult to work with such functions if you use Query Keys that are mixed Arrays and Strings. The same was true when using global callbacks.
64
64
65
65
To streamline all apis, we've decided to make all keys Arrays only:
66
66
@@ -100,7 +100,7 @@ Please note in the case of `TypeScript` you need to use `tsx` as the parser; oth
100
100
101
101
### The idle state has been removed
102
102
103
-
With the introduction of the new [fetchStatus](../queries#fetchstatus) for better offline support, the `idle` state became irrelevant, because `fetchStatus: 'idle'` captures the same state better. For more information, please read [Why two different states](../queries#why-two-different-states).
103
+
With the introduction of the new [fetchStatus](./queries.md#fetchstatus) for better offline support, the `idle` state became irrelevant, because `fetchStatus: 'idle'` captures the same state better. For more information, please read [Why two different states](./queries.md#why-two-different-states).
104
104
105
105
This will mostly affect `disabled` queries that don't have any `data` yet, as those were in `idle` state before:
106
106
@@ -110,7 +110,7 @@ This will mostly affect `disabled` queries that don't have any `data` yet, as th
110
110
+fetchStatus: 'idle'// [!code ++]
111
111
```
112
112
113
-
Also, have a look at [the guide on dependent queries](../dependent-queries)
113
+
Also, have a look at [the guide on dependent queries](./dependent-queries.md)
114
114
115
115
#### disabled queries
116
116
@@ -121,7 +121,7 @@ Due to this change, disabled queries (even temporarily disabled ones) will start
121
121
isInitialLoading// [!code ++]
122
122
```
123
123
124
-
See also the guide on [disabling queries](../disabling-queries#isInitialLoading)
124
+
See also the guide on [disabling queries](./disabling-queries.md#isInitialLoading)
125
125
126
126
### new API for `useQueries`
127
127
@@ -142,7 +142,7 @@ The `useQueries` hook now accepts an object with a `queries` prop as its input.
142
142
143
143
### Undefined is an illegal cache value for successful queries
144
144
145
-
In order to make bailing out of updates possible by returning `undefined`, we had to make `undefined` an illegal cache value. This is in-line with other concepts of react-query, for example, returning `undefined` from the [initialData function](../initial-query-data#initial-data-function) will also _not_ set data.
145
+
In order to make bailing out of updates possible by returning `undefined`, we had to make `undefined` an illegal cache value. This is in-line with other concepts of react-query, for example, returning `undefined` from the [initialData function](./initial-query-data.md#initial-data-function) will also _not_ set data.
146
146
147
147
Further, it is an easy bug to produce `Promise<void>` by adding logging in the queryFn:
148
148
@@ -156,7 +156,7 @@ This is now disallowed on type level; at runtime, `undefined` will be transforme
156
156
157
157
### Queries and mutations, per default, need network connection to run
158
158
159
-
Please read the [New Features announcement](#proper-offline-support) about online / offline support, and also the dedicated page about [Network mode](../network-mode)
159
+
Please read the [New Features announcement](#proper-offline-support) about online / offline support, and also the dedicated page about [Network mode](./network-mode.md)
160
160
161
161
Even though React Query is an Async State Manager that can be used for anything that produces a Promise, it is most often used for data fetching in combination with data fetching libraries. That is why, per default, queries and mutations will be `paused` if there is no network connection. If you want to opt-in to the previous behavior, you can globally set `networkMode: offlineFirst` for both queries and mutations:
A [query filter](../filters) is an object with certain conditions to match a query. Historically, the filter options have mostly been a combination of boolean flags. However, combining those flags can lead to impossible states. Specifically:
220
+
A [query filter](./filters.md) is an object with certain conditions to match a query. Historically, the filter options have mostly been a combination of boolean flags. However, combining those flags can lead to impossible states. Specifically:
221
221
222
222
```
223
223
active?: boolean
@@ -242,7 +242,7 @@ The filter defaults to `all`, and you can choose to only match `active` or `inac
242
242
243
243
#### refetchActive / refetchInactive
244
244
245
-
[queryClient.invalidateQueries](../../../../reference/QueryClient/#queryclientinvalidatequeries) had two additional, similar flags:
245
+
[queryClient.invalidateQueries](../../../reference/QueryClient.md#queryclientinvalidatequeries) had two additional, similar flags:
### `persistQueryClient` and the corresponding persister plugins are no longer experimental and have been renamed
282
282
283
-
The plugins `createWebStoragePersistor` and `createAsyncStoragePersistor` have been renamed to [`createSyncStoragePersister`](../../plugins/createSyncStoragePersister) and [`createAsyncStoragePersister`](../../plugins/createAsyncStoragePersister) respectively. The interface `Persistor` in `persistQueryClient` has also been renamed to `Persister`. Checkout [this stackexchange](https://english.stackexchange.com/questions/206893/persister-or-persistor) for the motivation of this change.
283
+
The plugins `createWebStoragePersistor` and `createAsyncStoragePersistor` have been renamed to [`createSyncStoragePersister`](../plugins/createSyncStoragePersister.md) and [`createAsyncStoragePersister`](../plugins/createAsyncStoragePersister.md) respectively. The interface `Persistor` in `persistQueryClient` has also been renamed to `Persister`. Checkout [this stackexchange](https://english.stackexchange.com/questions/206893/persister-or-persistor) for the motivation of this change.
284
284
285
285
Since these plugins are no longer experimental, their import paths have also been updated:
286
286
@@ -296,7 +296,7 @@ Since these plugins are no longer experimental, their import paths have also bee
296
296
297
297
### The `cancel` method on promises is no longer supported
298
298
299
-
The [old `cancel` method](../query-cancellation#old-cancel-function) that allowed you to define a `cancel` function on promises, which was then used by the library to support query cancellation, has been removed. We recommend to use the [newer API](../query-cancellation) (introduced with v3.30.0) for query cancellation that uses the [`AbortController` API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) internally and provides you with an [`AbortSignal` instance](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for your query function to support query cancellation.
299
+
The [old `cancel` method](./query-cancellation.md#old-cancel-function) that allowed you to define a `cancel` function on promises, which was then used by the library to support query cancellation, has been removed. We recommend to use the [newer API](./query-cancellation.md) (introduced with v3.30.0) for query cancellation that uses the [`AbortController` API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) internally and provides you with an [`AbortSignal` instance](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for your query function to support query cancellation.
300
300
301
301
### TypeScript
302
302
@@ -427,7 +427,7 @@ React Query defaults to "tracking" query properties, which should give you a nic
427
427
428
428
### Bailing out of updates with setQueryData
429
429
430
-
When using the [functional updater form of setQueryData](../../../../reference/QueryClient/#queryclientsetquerydata), you can now bail out of the update by returning `undefined`. This is helpful if `undefined` is given to you as `previousValue`, which means that currently, no cached entry exists and you don't want to / cannot create one, like in the example of toggling a todo:
430
+
When using the [functional updater form of setQueryData](../../../reference/QueryClient.md#queryclientsetquerydata), you can now bail out of the update by returning `undefined`. This is helpful if `undefined` is given to you as `previousValue`, which means that currently, no cached entry exists and you don't want to / cannot create one, like in the example of toggling a todo:
Copy file name to clipboardExpand all lines: docs/framework/react/guides/migrating-to-v5.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -218,7 +218,7 @@ useQuery<number, string>({
218
218
})
219
219
```
220
220
221
-
For a way to set a different kind of Error globally, see [the TypeScript Guide](../../typescript#registering-a-global-error).
221
+
For a way to set a different kind of Error globally, see [the TypeScript Guide](../typescript.md#registering-a-global-error).
222
222
223
223
### eslint `prefer-query-object-syntax` rule is removed
224
224
@@ -480,7 +480,7 @@ if (queryInfo.data) {
480
480
}
481
481
```
482
482
483
-
Here, we are only changing how the UI looks when the mutation is running instead of writing data directly to the cache. This works best if we only have one place where we need to show the optimistic update. For more details, have a look at the [optimistic updates documentation](../optimistic-updates).
483
+
Here, we are only changing how the UI looks when the mutation is running instead of writing data directly to the cache. This works best if we only have one place where we need to show the optimistic update. For more details, have a look at the [optimistic updates documentation](./optimistic-updates.md).
484
484
485
485
### Limited, Infinite Queries with new maxPages option
486
486
@@ -494,21 +494,21 @@ Note that the infinite list must be bi-directional, which requires both `getNext
494
494
495
495
### Infinite Queries can prefetch multiple pages
496
496
497
-
Infinite Queries can be prefetched like regular Queries. Per default, only the first page of the Query will be prefetched and will be stored under the given QueryKey. If you want to prefetch more than one page, you can use the `pages` option. Read the [prefetching guide](../prefetching) for more information.
497
+
Infinite Queries can be prefetched like regular Queries. Per default, only the first page of the Query will be prefetched and will be stored under the given QueryKey. If you want to prefetch more than one page, you can use the `pages` option. Read the [prefetching guide](./prefetching.md) for more information.
498
498
499
499
### New `combine` option for `useQueries`
500
500
501
-
See the [useQueries docs](../../reference/useQueries#combine) for more details.
501
+
See the [useQueries docs](../reference/useQueries.md#combine) for more details.
502
502
503
503
### Experimental `fine grained storage persister`
504
504
505
-
See the [experimental_createPersister docs](../../../react/plugins/createPersister) for more details.
505
+
See the [experimental_createPersister docs](../plugins/createPersister.md) for more details.
506
506
507
507
[//]: #'FrameworkSpecificNewFeatures'
508
508
509
509
### Typesafe way to create Query Options
510
510
511
-
See the [TypeScript docs](../../typescript#typing-query-options) for more details.
511
+
See the [TypeScript docs](../typescript.md#typing-query-options) for more details.
0 commit comments