Skip to content

Commit 1642154

Browse files
committed
Add a note on 2.x
1 parent 57b2ee2 commit 1642154

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ Thunk [middleware](http://redux.js.org/docs/advanced/Middleware.html) for Redux.
1111
npm install --save redux-thunk
1212
```
1313

14+
## Note on 2.x Update
15+
16+
Most tutorials today assume Redux Thunk 1.x so you might run into an issue when running their code with 2.x.
17+
**If you use Redux Thunk 2.x in CommonJS environment, [don’t forget to add `.default` to your import](https://github.com/gaearon/redux-thunk/releases/tag/v2.0.0):**
18+
19+
```diff
20+
- var ReduxThunk = require('redux-thunk')
21+
+ var ReduxThunk = require('redux-thunk').default
22+
```
23+
24+
If you used ES modules, you’re already all good:
25+
26+
```js
27+
import ReduxThunk from 'redux-thunk' // no changes here 😀
28+
```
29+
30+
Additionally, since 2.x, we also support a [UMD build](https://npmcdn.com/redux-thunk@2.0.1/dist/redux-thunk.min.js):
31+
32+
```js
33+
var ReduxThunk = window.ReduxThunk.default
34+
```
35+
36+
As you can see, it also requires `.default` at the end.
37+
1438
## Why Do I Need This?
1539

1640
If you’re not sure whether you need it, you probably don’t.

0 commit comments

Comments
 (0)