From b721292b350302c9480b4d7ec0b0b79ad7055cdc Mon Sep 17 00:00:00 2001 From: Tom Spencer Date: Mon, 4 Dec 2023 23:19:38 +0000 Subject: [PATCH 1/2] Update README to use named `thunk` export --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ca43146..43751a7 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ npm install redux-thunk yarn add redux-thunk ``` -The thunk middleware is the default export. +The thunk middleware is a named export.
More Details: Importing the thunk middleware @@ -48,22 +48,20 @@ The thunk middleware is the default export. If you're using ES modules: ```js -import thunk from 'redux-thunk' // no changes here 😀 +import { thunk } from 'redux-thunk' ``` -If you use Redux Thunk 2.x in a CommonJS environment, -[don’t forget to add `.default` to your import](https://github.com/reduxjs/redux-thunk/releases/tag/v2.0.0): +If you use Redux Thunk in a CommonJS environment: -```diff -- const thunk = require('redux-thunk') -+ const thunk = require('redux-thunk').default +```js +const { thunk } = require('redux-thunk') ``` Additionally, since 2.x, we also support a [UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js) for use as a global script tag: ```js -const ReduxThunk = window.ReduxThunk +const ReduxThunk = window.ReduxThunk.thunk ```
@@ -73,7 +71,7 @@ Then, to enable Redux Thunk, use ```js import { createStore, applyMiddleware } from 'redux' -import thunk from 'redux-thunk' +import { thunk } from 'redux-thunk' import rootReducer from './reducers/index' const store = createStore(rootReducer, applyMiddleware(thunk)) From 2fbc5351b9c554afa2b7ba4cde4ef314bc54047c Mon Sep 17 00:00:00 2001 From: Tom Spencer Date: Tue, 5 Dec 2023 10:33:36 +0000 Subject: [PATCH 2/2] Remove reference to UMD build --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 43751a7..e3c5a3b 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,6 @@ If you use Redux Thunk in a CommonJS environment: const { thunk } = require('redux-thunk') ``` -Additionally, since 2.x, we also support a -[UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js) for use as a global script tag: - -```js -const ReduxThunk = window.ReduxThunk.thunk -``` - Then, to enable Redux Thunk, use @@ -253,7 +246,7 @@ Promises to wait for each other’s completion: ```js import { createStore, applyMiddleware } from 'redux' -import thunk from 'redux-thunk' +import { thunk } from 'redux-thunk' import rootReducer from './reducers' // Note: this API requires redux@>=3.1.0