@@ -40,30 +40,28 @@ 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 ) :
54
+ If you use Redux Thunk in a CommonJS environment:
56
55
57
- ``` diff
58
- - const thunk = require('redux-thunk')
59
- + const thunk = require('redux-thunk').default
56
+ ``` js
57
+ const { thunk } = require (' redux-thunk' )
60
58
```
61
59
62
60
Additionally, since 2.x, we also support a
63
61
[ UMD build] ( https://unpkg.com/redux-thunk/dist/redux-thunk.min.js ) for use as a global script tag:
64
62
65
63
``` js
66
- const ReduxThunk = window .ReduxThunk
64
+ const ReduxThunk = window .ReduxThunk . thunk
67
65
```
68
66
69
67
</details >
@@ -73,7 +71,7 @@ Then, to enable Redux Thunk, use
73
71
74
72
``` js
75
73
import { createStore , applyMiddleware } from ' redux'
76
- import thunk from ' redux-thunk'
74
+ import { thunk } from ' redux-thunk'
77
75
import rootReducer from ' ./reducers/index'
78
76
79
77
const store = createStore (rootReducer, applyMiddleware (thunk))
0 commit comments