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/guides/migrating-to-react-query-4.md
+35-1Lines changed: 35 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ title: Migrating to React Query 4
5
5
6
6
## Breaking Changes
7
7
8
+
v4 is a major version, so there are some breaking changes to be aware of:
9
+
8
10
### react-query is now @tanstack/react-query
9
11
10
12
```diff
@@ -15,6 +17,32 @@ title: Migrating to React Query 4
15
17
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
16
18
```
17
19
20
+
#### Codemod
21
+
22
+
To make this migration easier, v4 comes with a codemod.
23
+
24
+
> The codemod is a best efforts attempt to help you migrate the breaking change. Please review the generated code thoroughly! Also, there are edge cases that cannot be found by the code mod, so please keep an eye on the log output.
25
+
26
+
You can easily apply it by using one (or both) of the following commands:
27
+
28
+
If you want to run it against `.js` or `.jsx` files, please use the command below:
Please note in the case of `TypeScript` you need to use `tsx` as the parser; otherwise, the codemod won't be applied properly!
41
+
42
+
**Note:** Applying the codemod might break your code formatting, so please don't forget to run `prettier` and/or `eslint` after you've applied the codemod!
43
+
44
+
**Note:** The codemod will _only_ change the imports - you still have to install the separate devtools package manually.
45
+
18
46
### Query Keys (and Mutation Keys) need to be an Array
19
47
20
48
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.
@@ -48,7 +76,7 @@ If you want to run it against `.ts` or `.tsx` files, please use the command belo
Please note in the case of `TypeScript` you need to use `tsx` as the parser otherwise, the codemod won't be applied properly!
79
+
Please note in the case of `TypeScript` you need to use `tsx` as the parser; otherwise, the codemod won't be applied properly!
52
80
53
81
**Note:** Applying the codemod might break your code formatting, so please don't forget to run `prettier` and/or `eslint` after you've applied the codemod!
54
82
@@ -335,6 +363,12 @@ If you were importing anything from `'react-query/react'` directly in your proje
335
363
336
364
## New Features 🚀
337
365
366
+
v4 comes with an awesome set of new features:
367
+
368
+
### Support for React 18
369
+
370
+
React 18 was released earlier this year, and v4 now has first class support for it and the new concurrent features it brings.
371
+
338
372
### Proper offline support
339
373
340
374
In v3, React Query has always fired off queries and mutations, but then taken the assumption that if you want to retry it, you need to be connected to the internet. This has led to several confusing situations:
0 commit comments