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/transition-guides/v2.md
+17-15Lines changed: 17 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,16 @@
1
-
# Important things to know
1
+
# redux-query 1.x to 2.x Transition Guide
2
2
3
-
## superagent has been updated to 3.x
3
+
## Important things to know
4
+
5
+
### superagent has been updated to 3.x
4
6
5
7
Any code that relied on the older version may need to be updated.
6
8
7
-
## Mutations have a subtly different behavior when updating entities
9
+
###Mutations have a subtly different behavior when updating entities
8
10
9
11
Motivation:
10
12
11
-
With redux-query 1.x, if you have simultaneous mutations that update the same entity, you could end up in with one mutation completely overwriting the changes of the other one. This is because the entities state for the update is captured before the network request starts, as opposed to when it finishes. Naturally, this has confused several people and just feels wrong.
13
+
With redux-query 1.x, if you have simultaneous mutations that update the same entity, you could end up in with one mutation completely overwriting the changes of the other one. This is because the entities state for the update is captured before the network request starts, as opposed to when it finishes.
12
14
13
15
Solution:
14
16
@@ -19,7 +21,7 @@ Breaking changes:
19
21
- Logic depending on the previous behavior will break and need to be updated.
20
22
- The returned value to the promise on mutation failures no longer include the "entities" field.
21
23
22
-
## New rollback behavior for optimistically-updated entities
24
+
###New rollback behavior for optimistically-updated entities
23
25
24
26
Motivation:
25
27
@@ -33,23 +35,23 @@ Additionally, we now offer a custom hook in query configs to enable manual contr
33
35
34
36
See the README for more information on the `rollback` field.
35
37
36
-
## New optional reducer for tracking failed query response data
38
+
###New optional reducer for tracking failed query response data
37
39
38
40
redux-query 2 exports a new reducer `errorsReducer` and accompanying set of selectors, `errorSelectors`. See the README for more information.
39
41
40
-
# Other actions to take
42
+
##Other actions to take
41
43
42
-
## Update all references to `request` field in actions and queries state
44
+
###Update all references to `request` field in actions and queries state
43
45
44
46
The `request` fields in the start actions and stored in the queries reducer state has been removed in favor of a new field called `networkHandler`.
45
47
46
48
`networkHandler` is the returned value from the network interface, not the underlying superagent instance. When using redux-query in its default mode with the superagent network interface, you can get the superagent instance with `networkHandler.instance`.
47
49
48
-
## Replace `removeEntity`/`REMOVE_ENTITY` and `removeEntities`/`REMOVE_ENTITIES` with `updateEntities`/`UPDATE_ENTITIES`
50
+
###Replace `removeEntity` and `removeEntities` with `updateEntities`
49
51
50
52
`REMOVE_ENTITY` and `REMOVE_ENTITIES` actions have been replaced with a more generic UPDATE_ENTITIES action.
51
53
52
-
Example:
54
+
For example, the following 1.x redux-query usage:
53
55
54
56
```javascript
55
57
import { removeEntity } from'redux-query';
@@ -68,11 +70,11 @@ dispatch(updateEntities({
68
70
}));
69
71
```
70
72
71
-
## Update all references to `reconcileQueryKey` and `getQueryKey`
73
+
###Update all references to `reconcileQueryKey` and `getQueryKey`
72
74
73
75
`reconcileQueryKey` and `getQueryKey` have been combined into a single function: `getQueryKey`. This function no longer accepts separate `url` and `body` parameters – instead you must pass a query config (or query-config-like object).
74
76
75
-
Example:
77
+
For example, the following 1.x redux-query usage:
76
78
77
79
```javascript
78
80
import { getQueryKey } from'redux-query';
@@ -86,14 +88,14 @@ import { getQueryKey } from 'redux-query';
86
88
constqueryKey=getQueryKey(query);
87
89
```
88
90
89
-
## Update all references to `querySelectors`
91
+
###Update all references to `querySelectors`
90
92
91
93
All selectors in `querySelectors` have changed their signatures. The queries state is now the first argument, with a query config (or query-config-like object) as the second parameter.
92
94
93
-
## Replace imports of `actions`, as it's no longer exported
95
+
###Replace imports of `actions`, as it's no longer exported
94
96
95
97
If you were importing `actions` from redux-query, you should change to import the actions directly. The only supported actions that are exported are: `cancelQuery`, `mutateAsync`, `requestAsync`, and `updateEntities`.
96
98
97
-
## Rename "adapters" to "network interfaces"
99
+
###Rename "adapters" to "network interfaces"
98
100
99
101
This is not a breaking change, but if you use `queryMiddlewareAdvanced` – I recommend renaming any references to "adapters" to prevent future confusion.
0 commit comments