Skip to content

Commit d506ba7

Browse files
committed
Improve v2 transition guide
1 parent 6504301 commit d506ba7

File tree

1 file changed

+17
-15
lines changed
  • docs/transition-guides

1 file changed

+17
-15
lines changed

docs/transition-guides/v2.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# Important things to know
1+
# redux-query 1.x to 2.x Transition Guide
22

3-
## superagent has been updated to 3.x
3+
## Important things to know
4+
5+
### superagent has been updated to 3.x
46

57
Any code that relied on the older version may need to be updated.
68

7-
## Mutations have a subtly different behavior when updating entities
9+
### Mutations have a subtly different behavior when updating entities
810

911
Motivation:
1012

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.
1214

1315
Solution:
1416

@@ -19,7 +21,7 @@ Breaking changes:
1921
- Logic depending on the previous behavior will break and need to be updated.
2022
- The returned value to the promise on mutation failures no longer include the "entities" field.
2123

22-
## New rollback behavior for optimistically-updated entities
24+
### New rollback behavior for optimistically-updated entities
2325

2426
Motivation:
2527

@@ -33,23 +35,23 @@ Additionally, we now offer a custom hook in query configs to enable manual contr
3335

3436
See the README for more information on the `rollback` field.
3537

36-
## New optional reducer for tracking failed query response data
38+
### New optional reducer for tracking failed query response data
3739

3840
redux-query 2 exports a new reducer `errorsReducer` and accompanying set of selectors, `errorSelectors`. See the README for more information.
3941

40-
# Other actions to take
42+
## Other actions to take
4143

42-
## Update all references to `request` field in actions and queries state
44+
### Update all references to `request` field in actions and queries state
4345

4446
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`.
4547

4648
`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`.
4749

48-
## Replace `removeEntity`/`REMOVE_ENTITY` and `removeEntities`/`REMOVE_ENTITIES` with `updateEntities`/`UPDATE_ENTITIES`
50+
### Replace `removeEntity` and `removeEntities` with `updateEntities`
4951

5052
`REMOVE_ENTITY` and `REMOVE_ENTITIES` actions have been replaced with a more generic UPDATE_ENTITIES action.
5153

52-
Example:
54+
For example, the following 1.x redux-query usage:
5355

5456
```javascript
5557
import { removeEntity } from 'redux-query';
@@ -68,11 +70,11 @@ dispatch(updateEntities({
6870
}));
6971
```
7072

71-
## Update all references to `reconcileQueryKey` and `getQueryKey`
73+
### Update all references to `reconcileQueryKey` and `getQueryKey`
7274

7375
`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).
7476

75-
Example:
77+
For example, the following 1.x redux-query usage:
7678

7779
```javascript
7880
import { getQueryKey } from 'redux-query';
@@ -86,14 +88,14 @@ import { getQueryKey } from 'redux-query';
8688
const queryKey = getQueryKey(query);
8789
```
8890

89-
## Update all references to `querySelectors`
91+
### Update all references to `querySelectors`
9092

9193
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.
9294

93-
## Replace imports of `actions`, as it's no longer exported
95+
### Replace imports of `actions`, as it's no longer exported
9496

9597
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`.
9698

97-
## Rename "adapters" to "network interfaces"
99+
### Rename "adapters" to "network interfaces"
98100

99101
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

Comments
 (0)