Skip to content

Commit 0f7a9e5

Browse files
committed
Merge branch 'master' into feature/1824-transform-placeholder-data-with-select
2 parents 0fbe732 + 94986b4 commit 0f7a9e5

31 files changed

+288
-126
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"no-shadow": "error",
3131
"import/no-cycle": "error",
32-
"import/no-unresolved": "error",
32+
"import/no-unresolved": ["error", { "ignore": ["react-query"] }],
3333
"import/no-unused-modules": ["off", { "unusedExports": true }],
3434
"no-redeclare": "off"
3535
}

.github/workflows/test-and-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node: [10, 12, 14]
19+
node: [10, 12, 14, 16]
2020
steps:
2121
- uses: actions/checkout@v2
22-
- uses: actions/setup-node@v1
22+
- uses: actions/setup-node@v2
2323
with:
2424
node-version: ${{ matrix.node }}
2525
- name: Install dependencies
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v2
37-
- uses: actions/setup-node@v1
37+
- uses: actions/setup-node@v2
3838
with:
3939
node-version: 14
4040
registry-url: https://registry.npmjs.org/

docs/src/pages/guides/filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ A query filter is an object with certain conditions to match a query with:
1313
// Cancel all queries
1414
await queryClient.cancelQueries()
1515

16-
// Remove all inactive queries
16+
// Remove all inactive queries that begin with `posts` in the key
1717
queryClient.removeQueries('posts', { inactive: true })
1818

1919
// Refetch all active queries
2020
await queryClient.refetchQueries({ active: true })
2121

22-
// Refetch all active queries that begin with `post` in the key
22+
// Refetch all active queries that begin with `posts` in the key
2323
await queryClient.refetchQueries('posts', { active: true })
2424
```
2525

docs/src/pages/guides/migrating-to-react-query-3.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const queryClient = new QueryClient()
4848

4949
Default options for queries and mutations can now be specified in `QueryClient`:
5050

51+
**Notice that it's now defaultOptions instead of defaultConfig**
52+
5153
```js
5254
const queryClient = new QueryClient({
5355
defaultOptions: {
@@ -147,7 +149,7 @@ They were previously added as the last query key parameter in your query functio
147149
useInfiniteQuery(['posts'], (_key, pageParam = 0) => fetchPosts(pageParam))
148150

149151
// New
150-
useInfiniteQuery(['posts'], ({ pageParam = 0 }) => fetchPost(pageParam))
152+
useInfiniteQuery(['posts'], ({ pageParam = 0 }) => fetchPosts(pageParam))
151153
```
152154

153155
### usePaginatedQuery() has been deprecated in favor of the `keepPreviousData` option

docs/src/pages/guides/mutations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ A mutation can only be in one of the following states at any given moment:
4444
- `isError` or `status === 'error'` - The mutation encountered an error
4545
- `isSuccess` or `status === 'success'` - The mutation was successful and mutation data is available
4646

47-
Beyond those primary state, more information is available depending on the state the mutation:
47+
Beyond those primary states, more information is available depending on the state of the mutation:
4848

4949
- `error` - If the mutation is in an `isError` state, the error is available via the `error` property.
5050
- `data` - If the mutation is in a `success` state, the data is available via the `data` property.
@@ -53,10 +53,10 @@ In the example above, you also saw that you can pass variables to your mutations
5353

5454
Even with just variables, mutations aren't all that special, but when used with the `onSuccess` option, the [Query Client's `invalidateQueries` method](../reference/QueryClient#queryclientinvalidatequeries) and the [Query Client's `setQueryData` method](../reference/QueryClient#queryclientsetquerydata), mutations become a very powerful tool.
5555

56-
> IMPORTANT: The `mutate` function is an asynchronous function, which means you cannot use it directly in an event callback. If you need to access the event in `onSubmit` you need to wrap `mutate` in another function. This is due to [React event pooling](https://reactjs.org/docs/events.html#event-pooling).
56+
> IMPORTANT: The `mutate` function is an asynchronous function, which means you cannot use it directly in an event callback in **React 16 and earlier**. If you need to access the event in `onSubmit` you need to wrap `mutate` in another function. This is due to [React event pooling](https://reactjs.org/docs/legacy-event-pooling.html).
5757
5858
```js
59-
// This will not work
59+
// This will not work in React 16 and earlier
6060
const CreateTodo = () => {
6161
const mutation = useMutation(event => {
6262
event.preventDefault()

docs/src/pages/guides/placeholder-query-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ In some circumstances, you may be able to provide the placeholder data for a que
4343

4444
```js
4545
function Todo({ blogPostId }) {
46-
const result = useQuery(['blogPost', blogPostId], () => fetch('/blogPosts'), {
46+
const result = useQuery(['blogPost', blogPostId], () => fetch(`/blogPosts/${blogPostId}`), {
4747
placeholderData: () => {
4848
// Use the smaller/preview version of the blogPost from the 'blogPosts' query as the placeholder data for this blogPost query
4949
return queryClient

docs/src/pages/guides/updates-from-mutation-responses.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ When dealing with mutations that **update** objects on the server, it's common f
99
const queryClient = useQueryClient()
1010

1111
const mutation = useMutation(editTodo, {
12-
onSuccess: data => queryClient.setQueryData(['todo', { id: 5 }], data),
12+
onSuccess: data => {
13+
queryClient.setQueryData(['todo', { id: 5 }], data)
14+
}
1315
})
1416

1517
mutation.mutate({

docs/src/pages/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Once you grasp the nature of server state in your application, **even more chall
2020

2121
- Caching... (possibly the hardest thing to do in programming)
2222
- Deduping multiple requests for the same data into a single request
23-
- Updating out of date data in the background
23+
- Updating "out of date" data in the background
2424
- Knowing when data is "out of date"
2525
- Reflecting updates to data as quickly as possible
2626
- Performance optimizations like pagination and lazy loading data

docs/src/pages/plugins/persistQueryClient.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ interface PersistQueryClientOptions {
9494
/** A unique string that can be used to forcefully
9595
* invalidate existing caches if they do not share the same buster string */
9696
buster?: string
97+
/** The options passed to the hydrate function */
98+
hydrateOptions?: HydrateOptions
99+
/** The options passed to the dehydrate function */
100+
dehydrateOptions?: DehydrateOptions
97101
}
98102
```
99103

docs/src/pages/reference/useMutation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ mutate(variables, {
4646
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
4747
- Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
4848
- The value returned from this function will be passed to both the `onError` and `onSettled` functions in the event of a mutation failure and can be useful for rolling back optimistic updates.
49-
- `onSuccess: (data: TData, variables: TVariables, context?: TContext) => Promise<void> | void`
49+
- `onSuccess: (data: TData, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5050
- Optional
5151
- This function will fire when the mutation is successful and will be passed the mutation's result.
5252
- If a promise is returned, it will be awaited and resolved before proceeding
53-
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
53+
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5454
- Optional
5555
- This function will fire if the mutation encounters an error and will be passed the error.
5656
- If a promise is returned, it will be awaited and resolved before proceeding
57-
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
57+
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<unknown> | void`
5858
- Optional
5959
- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
6060
- If a promise is returned, it will be awaited and resolved before proceeding

0 commit comments

Comments
 (0)