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/src/pages/guides/migrating-to-react-query-4.md
+26-22Lines changed: 26 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,10 @@ title: Migrating to React Query 4
5
5
6
6
## Breaking Changes
7
7
8
+
### ESM Support
9
+
10
+
React Query now supports [package.json `"exports"`](https://nodejs.org/api/packages.html#exports) and is fully compatible with Node's native resolution for both CommonJS and ESM. We don't expect this to be a breaking change for most users, but this restricts the files you can import into your project to only the entry points we officially support.
11
+
8
12
### Query Keys (and Mutation Keys) need to be an Array
9
13
10
14
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.
@@ -222,12 +226,12 @@ Even though React Query is an Async State Manager that can be used for anything
222
226
newQueryClient({
223
227
defaultOptions: {
224
228
queries: {
225
-
networkMode:'offlineFirst'
229
+
networkMode:'offlineFirst',
226
230
},
227
231
mutations: {
228
-
networkmode:'offlineFirst'
229
-
}
230
-
}
232
+
networkmode:'offlineFirst',
233
+
},
234
+
},
231
235
})
232
236
```
233
237
@@ -240,7 +244,6 @@ The `useQueries` hook now accepts an object with a `queries` prop as its input.
### Removed undocumented methods from the `queryClient`, `query` and `mutation`
245
248
246
249
The methods `cancelMutatations` and `executeMutation` on the `QueryClient` were undocumented and unused internally, so we removed them. Since it was just a wrapper around a method available on the `mutationCache`, you can still use the functionality of `executeMutation`
@@ -289,10 +292,7 @@ In order to make bailing out of updates possible by returning `undefined`, we ha
289
292
Further, it is an easy bug to produce `Promise<void>` by adding logging in the queryFn:
This is now disallowed on type level; at runtime, `undefined` will be transformed to a _failed Promise_, which means you will get an `error`, which will also be logged to the console in development mode.
@@ -349,19 +349,18 @@ React Query defaults to "tracking" query properties, which should give you a nic
349
349
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:
Custom contexts can now be specified to pair hooks with their matching `Provider`. This is critical when there may be multiple React Query `Provider` instances in the component tree, and you need to ensure your hook uses the correct `Provider` instance.
361
360
362
361
An example:
363
362
364
-
1) Create a data package.
363
+
1. Create a data package.
365
364
366
365
```tsx
367
366
// Our first data package: @my-scope/container-data
0 commit comments