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/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](../guides/important-defaults) before reading this guide
6
+
> Please thoroughly read the [Important Defaults](./guides/important-defaults) before reading this guide
7
7
8
8
## Basic Example
9
9
@@ -23,7 +23,7 @@ Let's assume we are using the default `cacheTime` of **5 minutes** and the defau
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`, `isLoading`, 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) are updated (including `isFetching`, `isLoading`, 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 cache timeout is set using `cacheTime` to delete and garbage collect the query (defaults to **5 minutes**).
Copy file name to clipboardExpand all lines: docs/framework/react/guides/important-defaults.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Out of the box, TanStack Query is configured with **aggressive but sane** defaul
15
15
- The network is reconnected
16
16
- The query is optionally configured with a refetch interval
17
17
18
-
If you see a refetch that you are not expecting, it is likely because you just focused the window and TanStack Query is doing a [`refetchOnWindowFocus`](../guides/window-focus-refetching). During development, this will probably be triggered more frequently, especially because focusing between the Browser DevTools and your app will also cause a fetch, so be aware of that.
18
+
If you see a refetch that you are not expecting, it is likely because you just focused the window and TanStack Query is doing a [`refetchOnWindowFocus`](./guides/window-focus-refetching). During development, this will probably be triggered more frequently, especially because focusing between the Browser DevTools and your app will also cause a fetch, so be aware of that.
19
19
20
20
> To change this functionality, you can use options like `refetchOnMount`, `refetchOnWindowFocus`, `refetchOnReconnect` and `refetchInterval`.
21
21
@@ -38,7 +38,7 @@ If you see a refetch that you are not expecting, it is likely because you just f
38
38
39
39
Have a look at the following articles from our Community Resources for further explanations of the defaults:
You can also pass this function as part of the 2nd argument (`queryFilters`) to [queryClient.refetchQueries](../reference/QueryClient#queryclientrefetchqueries), [queryClient.invalidateQueries](../reference/QueryClient#queryclientinvalidatequeries) or [queryClient.resetQueries](../reference/QueryClient#queryclientresetqueries).
141
+
You can also pass this function as part of the 2nd argument (`queryFilters`) to [queryClient.refetchQueries](./reference/QueryClient#queryclientrefetchqueries), [queryClient.invalidateQueries](./reference/QueryClient#queryclientinvalidatequeries) or [queryClient.resetQueries](./reference/QueryClient#queryclientresetqueries).
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`](../guides/prefetching)
12
-
-[Manually place the data into the cache using `queryClient.setQueryData`](../guides/prefetching)
11
+
-[Prefetch the data using `queryClient.prefetchQuery`](./guides/prefetching)
12
+
-[Manually place the data into the cache using `queryClient.setQueryData`](./guides/prefetching)
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#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
+34-41Lines changed: 34 additions & 41 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:
@@ -393,7 +385,7 @@ import { setLogger } from 'react-query'
393
385
394
386
// Log with Sentry
395
387
setLogger({
396
-
error: error=> {
388
+
error: (error)=> {
397
389
Sentry.captureException(error)
398
390
},
399
391
})
@@ -418,13 +410,14 @@ setConsole({
418
410
419
411
In version 3 **this is done automatically when React Query is used in React Native**.
420
412
421
-
422
413
### Typescript
414
+
423
415
#### `QueryStatus` has been changed from an [enum](https://www.typescriptlang.org/docs/handbook/enums.html#string-enums) to a [union type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
424
416
425
417
So, if you were checking the status property of a query or mutation against a QueryStatus enum property you will have to check it now against the string literal the enum previously held for each property.
426
418
427
419
Therefore you have to change the enum properties to their equivalent string literal, like this:
420
+
428
421
-`QueryStatus.Idle` -> `'idle'`
429
422
-`QueryStatus.Loading` -> `'loading'`
430
423
-`QueryStatus.Error` -> `'error'`
@@ -460,7 +453,7 @@ import { useQuery } from 'react-query'
460
453
461
454
function User() {
462
455
const { data } =useQuery(['user'], fetchUser, {
463
-
select: user=>user.username,
456
+
select: (user)=>user.username,
464
457
})
465
458
return <div>Username: {data}</div>
466
459
}
@@ -512,7 +505,7 @@ A `QueryObserver` can be used to create and/or watch a query:
0 commit comments