@@ -40,30 +40,21 @@ npm install redux-thunk
40
40
yarn add redux-thunk
41
41
```
42
42
43
- The thunk middleware is the default export.
43
+ The thunk middleware is a named export.
44
44
45
45
<details >
46
46
<summary ><b >More Details: Importing the thunk middleware</b ></summary >
47
47
48
48
If you're using ES modules:
49
49
50
50
``` js
51
- import thunk from ' redux-thunk' // no changes here 😀
51
+ import { thunk } from ' redux-thunk'
52
52
```
53
53
54
- If you use Redux Thunk 2.x in a CommonJS environment,
55
- [ don’t forget to add ` .default ` to your import] ( https://github.com/reduxjs/redux-thunk/releases/tag/v2.0.0 ) :
56
-
57
- ``` diff
58
- - const thunk = require('redux-thunk')
59
- + const thunk = require('redux-thunk').default
60
- ```
61
-
62
- Additionally, since 2.x, we also support a
63
- [ UMD build] ( https://unpkg.com/redux-thunk/dist/redux-thunk.min.js ) for use as a global script tag:
54
+ If you use Redux Thunk in a CommonJS environment:
64
55
65
56
``` js
66
- const ReduxThunk = window . ReduxThunk
57
+ const { thunk } = require ( ' redux-thunk ' )
67
58
```
68
59
69
60
</details >
@@ -73,7 +64,7 @@ Then, to enable Redux Thunk, use
73
64
74
65
``` js
75
66
import { createStore , applyMiddleware } from ' redux'
76
- import thunk from ' redux-thunk'
67
+ import { thunk } from ' redux-thunk'
77
68
import rootReducer from ' ./reducers/index'
78
69
79
70
const store = createStore (rootReducer, applyMiddleware (thunk))
@@ -255,7 +246,7 @@ Promises to wait for each other’s completion:
255
246
256
247
``` js
257
248
import { createStore , applyMiddleware } from ' redux'
258
- import thunk from ' redux-thunk'
249
+ import { thunk } from ' redux-thunk'
259
250
import rootReducer from ' ./reducers'
260
251
261
252
// Note: this API requires redux@>=3.1.0
0 commit comments