Skip to content

Commit cadc517

Browse files
authored
Merge branch 'main' into devtools-in-prod
2 parents ab610c4 + 0650eaf commit cadc517

File tree

101 files changed

+313
-232
lines changed

Some content is hidden

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

101 files changed

+313
-232
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ 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 }}:

docs/framework/angular/devtools.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ title: Devtools
55

66
> 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:
77
>
8-
> - <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1" /> [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" /> [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" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
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)
1111
1212
## Enable devtools
1313

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Browser extensions for Chrome, Firefox, and Edge that provide devtools for TanSt
3737

3838
Links:
3939

40-
- <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1" /> [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" /> [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" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
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)
4343

4444
## GraphQL Code Generator
4545

docs/framework/react/devtools.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ When you begin your React Query journey, you'll want these devtools by your side
99

1010
> 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:
1111
>
12-
> - <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1" /> [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" /> [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" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj)
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)
1515
1616
> 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)
1717

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,25 @@ 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)
4050

4151
[//]: # 'Materials'

docs/framework/react/react-native.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ useEffect(() => {
7474
## Refresh on Screen focus
7575

7676
In some situations, you may want to refetch the query when a React Native Screen is focused again.
77-
This custom hook will call the provided `refetch` function when the screen is focused again.
77+
This custom hook will refetch **all active stale queries** when the screen is focused again.
7878

7979
```tsx
8080
import React from 'react'
8181
import { useFocusEffect } from '@react-navigation/native'
82+
import { useQueryClient } from '@tanstack/react-query'
8283

83-
export function useRefreshOnFocus<T>(refetch: () => Promise<T>) {
84+
export function useRefreshOnFocus() {
85+
const queryClient = useQueryClient()
8486
const firstTimeRef = React.useRef(true)
8587

8688
useFocusEffect(
@@ -90,13 +92,18 @@ export function useRefreshOnFocus<T>(refetch: () => Promise<T>) {
9092
return
9193
}
9294

93-
refetch()
94-
}, [refetch]),
95+
// refetch all stale active queries
96+
queryClient.refetchQueries({
97+
queryKey: ['posts'],
98+
stale: true,
99+
type: 'active',
100+
})
101+
}, [queryClient]),
95102
)
96103
}
97104
```
98105

99-
In the above code, `refetch` is skipped the first time because `useFocusEffect` calls our callback on mount in addition to screen focus.
106+
In the above code, the first focus (when the screen is initially mounted) is skipped because `useFocusEffect` calls our callback on mount in addition to screen focus.
100107

101108
## Disable queries on out of focus screens
102109

docs/framework/react/reference/hydration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ hydrate(queryClient, dehydratedState, options)
9191
- `mutations: MutationOptions` The default mutation options to use for the hydrated mutations.
9292
- `queries: QueryOptions` The default query options to use for the hydrated queries.
9393
- `deserializeData?: (data: any) => any` A function to transform (deserialize) data before it is put into the cache.
94-
- `queryClient?: QueryClient`,
94+
- `queryClient?: QueryClient`
9595
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
9696

9797
### Limitations
@@ -122,7 +122,7 @@ function App() {
122122
- Optional
123123
- `defaultOptions: QueryOptions`
124124
- The default query options to use for the hydrated queries.
125-
- `queryClient?: QueryClient`,
125+
- `queryClient?: QueryClient`
126126
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
127127

128128
[//]: # 'HydrationBoundary'

docs/framework/react/reference/useIsFetching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
1616
**Options**
1717

1818
- `filters?: QueryFilters`: [Query Filters](../../guides/filters.md#query-filters)
19-
- `queryClient?: QueryClient`,
19+
- `queryClient?: QueryClient`
2020
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
2121

2222
**Returns**

docs/framework/react/reference/useIsMutating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
1616
**Options**
1717

1818
- `filters?: MutationFilters`: [Mutation Filters](../../guides/filters.md#mutation-filters)
19-
- `queryClient?: QueryClient`,
19+
- `queryClient?: QueryClient`
2020
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
2121

2222
**Returns**

docs/framework/react/reference/useMutation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ mutate(variables, {
103103

104104
**Parameter2 (QueryClient)**
105105

106-
- `queryClient?: QueryClient`,
106+
- `queryClient?: QueryClient`
107107
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
108108

109109
**Returns**
@@ -128,7 +128,7 @@ mutate(variables, {
128128
- If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
129129
- `mutateAsync: (variables: TVariables, { onSuccess, onSettled, onError }) => Promise<TData>`
130130
- Similar to `mutate` but returns a promise which can be awaited.
131-
- `status: string`
131+
- `status: MutationStatus`
132132
- Will be:
133133
- `idle` initial status prior to the mutation function executing.
134134
- `pending` if the mutation is currently executing.

0 commit comments

Comments
 (0)