Skip to content

Commit dd20738

Browse files
docs: Fix relative links
1 parent bc67f24 commit dd20738

Some content is hidden

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

42 files changed

+347
-310
lines changed

docs/framework/react/guides/caching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: caching
33
title: Caching Examples
44
---
55

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
77
88
## Basic Example
99

@@ -23,7 +23,7 @@ Let's assume we are using the default `cacheTime` of **5 minutes** and the defau
2323
- A second instance of `useQuery({ queryKey: ['todos'], queryFn: fetchTodos })` mounts elsewhere.
2424
- Since the cache already has data for the `['todos']` key from the first query, that data is immediately returned from the cache.
2525
- 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.
2727
- 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.
2828
- Both instances of the `useQuery({ queryKey: ['todos'], queryFn: fetchTodos })` query are unmounted and no longer in use.
2929
- 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**).

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Out of the box, TanStack Query is configured with **aggressive but sane** defaul
1515
- The network is reconnected
1616
- The query is optionally configured with a refetch interval
1717

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.
1919

2020
> To change this functionality, you can use options like `refetchOnMount`, `refetchOnWindowFocus`, `refetchOnReconnect` and `refetchInterval`.
2121
@@ -38,7 +38,7 @@ If you see a refetch that you are not expecting, it is likely because you just f
3838

3939
Have a look at the following articles from our Community Resources for further explanations of the defaults:
4040

41-
- [Practical React Query](../community/tkdodos-blog#1-practical-react-query)
42-
- [React Query as a State Manager](../community/tkdodos-blog#10-react-query-as-a-state-manager)
41+
- [Practical React Query](./community/tkdodos-blog#1-practical-react-query)
42+
- [React Query as a State Manager](./community/tkdodos-blog#10-react-query-as-a-state-manager)
4343

4444
[//]: # 'Materials'

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function Projects() {
8787
{isFetchingNextPage
8888
? 'Loading more...'
8989
: hasNextPage
90-
? 'Load More'
91-
: 'Nothing more to load'}
90+
? 'Load More'
91+
: 'Nothing more to load'}
9292
</button>
9393
</div>
9494
<div>{isFetching && !isFetchingNextPage ? 'Fetching...' : null}</div>
@@ -110,9 +110,7 @@ To ensure a seamless querying process without conflicts, it's highly recommended
110110
[//]: # 'Example1'
111111

112112
```jsx
113-
<List
114-
onEndReached={() => !isFetching && fetchNextPage()}
115-
/>
113+
<List onEndReached={() => !isFetching && fetchNextPage()} />
116114
```
117115

118116
[//]: # 'Example1'
@@ -140,7 +138,7 @@ refetch({ refetchPage: (page, index) => index === 0 })
140138

141139
[//]: # 'Example2'
142140

143-
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).
144142

145143
**Signature**
146144

@@ -254,8 +252,8 @@ queryClient.setQueryData(['projects'], (data) => ({
254252

255253
```tsx
256254
queryClient.setQueryData(['projects'], (data) => ({
257-
pages: data.pages.slice(0,1),
258-
pageParams: data.pageParams.slice(0,1),
255+
pages: data.pages.slice(0, 1),
256+
pageParams: data.pageParams.slice(0, 1),
259257
}))
260258
```
261259

docs/framework/react/guides/initial-query-data.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ There are many ways to supply initial data for a query to the cache before you n
88
- Declaratively:
99
- Provide `initialData` to a query to prepopulate its cache if empty
1010
- 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)
1313

1414
## Using `initialData` to prepopulate a query
1515

@@ -170,6 +170,6 @@ const result = useQuery({
170170

171171
## Further reading
172172

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).
174174

175175
[//]: # 'Materials'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ const mutation = useMutation({
3636

3737
[//]: # 'Example2'
3838

39-
You can wire up your invalidations to happen using any of the callbacks available in the [`useMutation` hook](../guides/mutations)
39+
You can wire up your invalidations to happen using any of the callbacks available in the [`useMutation` hook](./guides/mutations)

docs/framework/react/guides/migrating-to-react-query-3.md

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ try {
103103

104104
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:
105105

106-
- [QueryErrorResetBoundary](../reference/QueryErrorResetBoundary)
107-
- [useQueryErrorResetBoundary](../reference/useQueryErrorResetBoundary)
106+
- [QueryErrorResetBoundary](./reference/QueryErrorResetBoundary)
107+
- [useQueryErrorResetBoundary](./reference/useQueryErrorResetBoundary)
108108

109109
### `QueryCache.getQuery()` has been replaced by `QueryCache.find()`.
110110

@@ -137,7 +137,7 @@ useQuery(['post', id], () => fetchPost(id))
137137
If you still insist on not using inline functions, you can use the newly passed `QueryFunctionContext`:
138138

139139
```tsx
140-
useQuery(['post', id], context => fetchPost(context.queryKey[1]))
140+
useQuery(['post', id], (context) => fetchPost(context.queryKey[1]))
141141
```
142142

143143
### Infinite Query Page params are now passed via `QueryFunctionContext.pageParam`
@@ -183,18 +183,14 @@ The `useInfiniteQuery()` interface has changed to fully support bi-directional i
183183
One direction:
184184

185185
```tsx
186-
const {
187-
data,
188-
fetchNextPage,
189-
hasNextPage,
190-
isFetchingNextPage,
191-
} = useInfiniteQuery(
192-
'projects',
193-
({ pageParam = 0 }) => fetchProjects(pageParam),
194-
{
195-
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
196-
}
197-
)
186+
const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
187+
useInfiniteQuery(
188+
'projects',
189+
({ pageParam = 0 }) => fetchProjects(pageParam),
190+
{
191+
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
192+
},
193+
)
198194
```
199195

200196
Both directions:
@@ -214,37 +210,33 @@ const {
214210
{
215211
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
216212
getPreviousPageParam: (firstPage, pages) => firstPage.prevCursor,
217-
}
213+
},
218214
)
219215
```
220216

221217
One direction reversed:
222218

223219
```tsx
224-
const {
225-
data,
226-
fetchNextPage,
227-
hasNextPage,
228-
isFetchingNextPage,
229-
} = useInfiniteQuery(
230-
'projects',
231-
({ pageParam = 0 }) => fetchProjects(pageParam),
232-
{
233-
select: data => ({
234-
pages: [...data.pages].reverse(),
235-
pageParams: [...data.pageParams].reverse(),
236-
}),
237-
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
238-
}
239-
)
220+
const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
221+
useInfiniteQuery(
222+
'projects',
223+
({ pageParam = 0 }) => fetchProjects(pageParam),
224+
{
225+
select: (data) => ({
226+
pages: [...data.pages].reverse(),
227+
pageParams: [...data.pageParams].reverse(),
228+
}),
229+
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
230+
},
231+
)
240232
```
241233

242234
### Infinite Query data now contains the array of pages and pageParams used to fetch those pages.
243235

244236
This allows for easier manipulation of the data and the page params, like, for example, removing the first page of data along with it's params:
245237

246238
```tsx
247-
queryClient.setQueryData(['projects'], data => ({
239+
queryClient.setQueryData(['projects'], (data) => ({
248240
pages: data.pages.slice(1),
249241
pageParams: data.pageParams.slice(1),
250242
}))
@@ -277,10 +269,10 @@ The `mutate` function can be used when using callbacks:
277269
const { mutate } = useMutation({ mutationFn: addTodo })
278270

279271
mutate('todo', {
280-
onSuccess: data => {
272+
onSuccess: (data) => {
281273
console.log(data)
282274
},
283-
onError: error => {
275+
onError: (error) => {
284276
console.error(error)
285277
},
286278
onSettled: () => {
@@ -393,7 +385,7 @@ import { setLogger } from 'react-query'
393385

394386
// Log with Sentry
395387
setLogger({
396-
error: error => {
388+
error: (error) => {
397389
Sentry.captureException(error)
398390
},
399391
})
@@ -418,13 +410,14 @@ setConsole({
418410

419411
In version 3 **this is done automatically when React Query is used in React Native**.
420412

421-
422413
### Typescript
414+
423415
#### `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)
424416

425417
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.
426418

427419
Therefore you have to change the enum properties to their equivalent string literal, like this:
420+
428421
- `QueryStatus.Idle` -> `'idle'`
429422
- `QueryStatus.Loading` -> `'loading'`
430423
- `QueryStatus.Error` -> `'error'`
@@ -460,7 +453,7 @@ import { useQuery } from 'react-query'
460453

461454
function User() {
462455
const { data } = useQuery(['user'], fetchUser, {
463-
select: user => user.username,
456+
select: (user) => user.username,
464457
})
465458
return <div>Username: {data}</div>
466459
}
@@ -512,7 +505,7 @@ A `QueryObserver` can be used to create and/or watch a query:
512505
```tsx
513506
const observer = new QueryObserver(queryClient, { queryKey: 'posts' })
514507

515-
const unsubscribe = observer.subscribe(result => {
508+
const unsubscribe = observer.subscribe((result) => {
516509
console.log(result)
517510
unsubscribe()
518511
})
@@ -530,7 +523,7 @@ const observer = new InfiniteQueryObserver(queryClient, {
530523
getPreviousPageParam: (firstPage, allPages) => firstPage.prevCursor,
531524
})
532525

533-
const unsubscribe = observer.subscribe(result => {
526+
const unsubscribe = observer.subscribe((result) => {
534527
console.log(result)
535528
unsubscribe()
536529
})
@@ -546,7 +539,7 @@ const observer = new QueriesObserver(queryClient, [
546539
{ queryKey: ['post', 2], queryFn: fetchPost },
547540
])
548541

549-
const unsubscribe = observer.subscribe(result => {
542+
const unsubscribe = observer.subscribe((result) => {
550543
console.log(result)
551544
unsubscribe()
552545
})

0 commit comments

Comments
 (0)