Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^2.3.0
->^3.0.0
Release Notes
reduxjs/redux-thunk (redux-thunk)
v3.1.0
Compare Source
This major release:
This release has breaking changes. (Note: this actually points to v3.1.0, which includes a hotfix that was meant for 3.0.0.)
This release is part of a wave of major versions of all the Redux packages: Redux Toolkit 2.0, Redux core 5.0, React-Redux 9.0, Reselect 5.0, and Redux Thunk 3.0.
For full details on all of the breaking changes and other significant changes to all of those packages, see the "Migrating to RTK 2.0 and Redux 5.0" migration guide in the Redux docs.
Changelog
Named Exports Instead of Default Exports
The
redux-thunk
package previously used a single default export that was the thunk middleware, with an attached field namedwithExtraArgument
that allowed customization.The default export has been removed. There are now two named exports:
thunk
(the basic middleware) andwithExtraArgument
.If you are using Redux Toolkit, this should have no effect, as RTK already handles this inside of
configureStore
.ESM/CJS Package Compatibility
The biggest theme of the Redux v5 and RTK 2.0 releases is trying to get "true" ESM package publishing compatibility in place, while still supporting CJS in the published package.
The primary build artifact is now an ESM file,
dist/redux-thunk.mjs
. Most build tools should pick this up. There's also a CJS artifact, and a second copy of the ESM file namedredux-thunk.legacy-esm.js
to support Webpack 4 (which does not recognize theexports
field inpackage.json
).Build Tooling
We're now building the package using https://github.com/egoist/tsup. We also now include sourcemaps for the ESM and CJS artifacts.
The repo has been updated to use Yarn 3 for dependencies and Vitest for running tests.
Dropping UMD Builds
Redux has always shipped with UMD build artifacts. These are primarily meant for direct import as script tags, such as in a CodePen or a no-bundler build environment.
For now, we're dropping those build artifacts from the published package, on the grounds that the use cases seem pretty rare today.
Since the code is so simple, the ESM artifact can be used directly in the browser via Unpkg.
If you have strong use cases for us continuing to include UMD build artifacts, please let us know!
extend-redux
Typedefs RemovedRedux Thunk 2.x included a
redux-thunk/extend-redux
TS-only entry point, which extended the types ofdispatch
andbindActionCreators
to globally give them knowledge of the thunk types. We feel that global overrides from a library are an anti-pattern, and we've removed this entry point. (Note: this ended up being released in 3.1.0, as it was missed in the original 3.0.0 release.)Please follow our TS setup guidelines to infer the correct type of
dispatch
for your store.What's Changed
redux-thunk
by @markerikson in https://github.com/reduxjs/redux-thunk/pull/345Full Changelog: reduxjs/redux-thunk@v2.4.2...v3.1.0
v3.0.1
Compare Source
v3.0.0
Compare Source
v2.4.2
Compare Source
This release removes an unused TS type that caused errors when users were type-checking libraries in
node_modules
.What's Changed
Full Changelog: reduxjs/redux-thunk@v2.4.1...v2.4.2
v2.4.1
Compare Source
This release adds an explicit plain
action
overload to theThunkDispatch
TS type to better handle inference of the return value in some cases.What's Changed
Full Changelog: reduxjs/redux-thunk@v2.4.0...v2.4.1
v2.4.0
Compare Source
This very overdue release makes several major improvements to the TypeScript types, and converts the actual source to TypeScript. Sorry for the delay!
Changelog
TypeScript Improvements
This release fixes several outstanding issues that had been reported with the types. An extra overload has been added to let TS correctly understand some generically-typed values being passed to
dispatch
, and the overloads have been reworked for additional compatibility.There's also a new
ThunkActionDispatch
type that can be used to represent howbindActionCreators
turns bound thunks into(arg) => thunkReturnValue
.Additionally, all of the generic args have been giving meaningful names instead of one-letter abbreviations (
S
->State
,E
->ExtraArgument
, etc), and we've added descriptive comments in the type definitions for clarity.Optional Global
Dispatch
Type ExtensionMost Redux apps have the thunk middleware enabled, but the default
Dispatch
andbindActionCreator
types only know about the standard behavior of a basic Redux store without any middleware. The thunk middleware types add to that type behavior, so thatDispatch
knows dispatching a thunk can actually return a value such as a Promise.We generally recommend inferring the type of
dispatch
and using that to create reusable types, including creating pre-typed hooks. However, some users may prefer to globally augment theDispatch
type to always use the additional thunk behavior.You can now
import 'redux-thunk/extend-redux'
to globally augment theDispatch
type as an opt-in change in behavior.Codebase Converted to TypeScript
We've gone ahead and converted the actual source to TS. Since the source was only 15-ish lines to begin with, most of the "conversion" time was just trying to convince TS that assigning
thunk.extraArgument = createThunkMiddleware
was a legal operation :)We also updated the build tooling:
Finally, the README has been updated with newer instructions and usage information.
What's Changed
applyMiddleware
by @iamandrewluca in https://github.com/reduxjs/redux-thunk/pull/279|
by @Philipp91 in https://github.com/reduxjs/redux-thunk/pull/317New Contributors
Full Changelog: reduxjs/redux-thunk@v2.3.0...v2.4.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.