NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #1379 most downloaded on npm
Predictable state container for JavaScript apps
Last release 3 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 10 months
Nearly every release is documented
notes for 57 of the last 60 stable releases
5 versions withdrawn
withdrawn after publishing
15 years old
85 releases · first in 2011
This patch release adjusts the isPlainObject util to allow objects created via Object.create(null) , and fixes a type issue which accidentally made th
This patch release adjusts the isPlainObject util to allow objects created via Object.create(null), and fixes a type issue which accidentally made the store state type non-nullable.
Store['getState'] by @exuanbo in #4638Full Changelog: v5.0.0...v5.0.1
One column per quarter.
This release has breaking changes .
This major release:
action.type must be a stringcreateStore as deprecatedAnyAction type in favor of an UnknownAction type that is used everywherePreloadedState type in favor of a new generic argument for the Reducer type.This release has breaking changes.
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.
Note
The Redux core, Reselect, and Redux Thunk packages are included as part of Redux Toolkit, and RTK users do not need to manually upgrade them - you'll get them as part of the upgrade to RTK 2.0. (If you're not using Redux Toolkit yet, please start migrating your existing legacy Redux code to use Redux Toolkit today!)
# RTK
npm install @reduxjs/toolkit
yarn add @reduxjs/toolkit
# Standalone
npm install redux
yarn add reduxThe 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.mjs. Most build tools should pick this up. There's also a CJS artifact, and a second copy of the ESM file named redux.legacy-esm.js to support Webpack 4 (which does not recognize the exports field in package.json). Additionally, all of the build artifacts now live under ./dist/ in the published package.
We now publish modern JS syntax targeting ES2020, including optional chaining, object spread, and other modern syntax. If you need to
We're now building the package using https://github.com/egoist/tsup. We also now include sourcemaps for the ESM and CJS artifacts.
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.
We've dropped those build artifacts from the published package, on the grounds that the use cases seem pretty rare today.
There's now a redux.browser.mjs file in the package that can be loaded from a CDN like Unpkg.
If you have strong use cases for us continuing to include UMD build artifacts, please let us know!
createStore Marked DeprecatedIn Redux 4.2.0, we marked the original createStore method as @deprecated. Strictly speaking, this is not a breaking change, nor is it new in 5.0, but we're documenting it here for completeness.
This deprecation is solely a visual indicator that is meant to encourage users to migrate their apps from legacy Redux patterns to use the modern Redux Toolkit APIs.
The deprecation results in a visual strikethrough when imported and used, like , but with no runtime errors or warnings.createStore
createStore will continue to work indefinitely, and will not ever be removed. But, today we want all Redux users to be using Redux Toolkit for all of their Redux logic.
To fix this, there are three options:
configureStorelegacy_createStore API that is now exported, which is the exact same function but with no @deprecated tag. The simplest option is to do an aliased import rename, like import { legacy_createStore as createStore } from 'redux'We've always specifically told our users that actions and state must be serializable, and that action.type should be a string. This is both to ensure that actions are serializable, and to help provide a readable action history in the Redux DevTools.
store.dispatch(action) now specifically enforces that action.type must be a string and will throw an error if not, in the same way it throws an error if the action is not a plain object.
In practice, this was already true 99.99% of the time and shouldn't have any effect on users (especially those using Redux Toolkit and createSlice), but there may be some legacy Redux codebases that opted to use Symbols as action types.
We've dropped support for TS 4.6 and earlier, and our support matrix is now TS 4.7+.
In 2019, we began a community-powered conversion of the Redux codebase to TypeScript. The original effort was discussed in #3500: Port to TypeScript, and the work was integrated in PR #3536: Convert to TypeScript.
However, the TS-converted code sat around in the repo for several years, unused and unpublished, due to concerns about possible compatibility issues with the existing ecosystem (as well as general inertia on our part).
Redux core v5 is now built from that TS-converted source code. In theory, this should be almost identical in both runtime behavior and types to the 4.x build, but it's very likely that some of the changes may cause types issues.
Please report any unexpected compatibility issues!!
AnyAction deprecated in favour of UnknownActionThe Redux TS types have always exported an AnyAction type, which is defined to have {type: string} and treat any other field as any. This makes it easy to write uses like console.log(action.whatever), but unfortunately does not provide any meaningful type safety.
We now export an UnknownAction type, which treats all fields other than action.type as unknown. This encourages users to write type guards that check the action object and assert its specific TS type. Inside of those checks, you can access a field with better type safety.
UnknownAction is now the default any place in the Redux source that expects an action object.
AnyAction still exists for compatibility, but has been marked as deprecated.
Note that Redux Toolkit's action creators have a .match() method that acts as a useful type guard:
if (todoAdded.match(someUnknownAction)) {
// action is now typed as a PayloadAction<Todo>
}You can also use the new isAction util to check if an unknown value is some kind of action object.
Middleware type changed - Middleware action and next are typed as unknownPreviously, the next parameter is typed as the D type parameter passed, and action is typed as the Action extracted from the dispatch type. Neither of these are a safe assumption:
next would be typed to have all of the dispatch extensions, including the ones earlier in the chain that would no longer apply.
next as the default Dispatch implemented by the base redux store, however this would cause next(action) to error (as we cannot promise action is actually an Action) - and it wouldn't account for any following middlewares that return anything other than the action they're given when they see a specific action.action is not necessarily a known action, it can be literally anything - for example a thunk would be a function with no .type property (so AnyAction would be inaccurate)We've changed next to be (action: unknown) => unknown (which is accurate, we have no idea what next expects or will return), and changed the action parameter to be unknown (which as above, is accurate).
In order to safely interact with values or access fields inside of the action argument, you must first do a type guard check to narrow the type, such as isAction(action) or someActionCreator.match(action).
This new type is incompatible with the v4 Middleware type, so if a package's middleware is saying it's incompatible, check which version of Redux it's getting its types from!
PreloadedState type removed in favour of Reducer genericWe've made tweaks to the TS types to improve type safety and behavior.
First, the Reducer type now has a PreloadedState possible generic:
type Reducer<S, A extends Action, PreloadedState = S> = (
state: S | PreloadedState | undefined,
action: A
) => SPer the explanation in #4491:
Why the need for this change? When the store is first created by createStore/configureStore, the initial state is set to whatever is passed as the preloadedState argument (or undefined if nothing is passed). That means that the first time that the reducer is called, it is called with the preloadedState. After the first call, the reducer is always passed the current state (which is S).
For most normal reducers, S | undefined accurately describes what can be passed in for the preloadedState. However the combineReducers function allows for a preloaded state of Partial<S> | undefined.
The solution is to have a separate generic that represents what the reducer accepts for its preloaded state. That way createStore can then use that generic for its preloadedState argument.
Previously, this was handled by a $CombinedState type, but that complicated things and led to some user-reported issues. This removes the need for $CombinedState altogether.
This change does include some breaking changes, but overall should not have a huge impact on users upgrading in user-land:
Reducer, ReducersMapObject, and createStore/configureStore types/function take an additional PreloadedState generic which defaults to S.combineReducers are removed in favor of a single function definition that takes the ReducersMapObject as its generic parameter. Removing the overloads was necessary with these changes, since sometimes it was choosing the wrong overload.The Redux store has always used an array to track listener callbacks, and used listeners.findIndex to remove listeners on unsubscribe. As we found in React-Redux, that can have perf issues when many listeners are unsubscribing at once.
In React-Redux, we fixed that with a more sophisticated linked list approach. Here, we've updated the listeners to be stored in a Map instead, which has better delete performance than an array.
In practice this shouldn't have any real effect, because React-Redux sets up a subscription in <Provider>, and all nested components subscribe to that. But, nice to fix it here as well.
isAction PredicateWe recently added an isAction predicate to RTK, then realized it's better suited for the Redux core. This can be used anywhere you have a value that could be a Redux action object, and you need to check if it is actually an action. This is specifically useful for use with the updated Redux middleware TS types, where the default value is now unknown and you need to use a type guard to tell TS that the current value is actually an action:
We've also exported the isPlainObject util that's been in the Redux codebase for years as well.
Entirely too many PRs to list here, as it's been a few years since 4.2 was released :) See the diff below.
Full Changelog: v4.2.1...v5.0.0
See the preview Redux Toolkit 2.0 + Redux core 5.0 Migration Guide for an overview of breaking changes in RTK 2.0 and Redux core.
This release candidate adds a new isAction predicate that can be used as a TS type guard, and exports the existing internal isPlainObject util.
Note that we hope to release Redux Toolkit 2.0, Redux core 5.0, and React-Redux 9.0 by the start of December! (If we don't hit that, we'll aim for January, after the holidays.)
See the preview Redux Toolkit 2.0 + Redux core 5.0 Migration Guide for an overview of breaking changes in RTK 2.0 and Redux core.
npm install redux@next
yarn add redux@nextisAction PredicateWe recently added an isAction predicate to RTK, then realized it's better suited for the Redux core. This can be used anywhere you have a value that could be a Redux action object, and you need to check if it is actually an action. This is specifically useful for use with the updated Redux middleware TS types, where the default value is now unknown and you need to use a type guard to tell TS that the current value is actually an action:
We've also exported the isPlainObject util that's been in the Redux codebase for years as well.
Full Changelog: v5.0.0-rc.0...v5.0.0-rc.1
See the preview Redux Toolkit 2.0 + Redux core 5.0 Migration Guide for an overview of breaking changes in RTK 2.0 and Redux core.
This release candidate has no actual source code changes since the previous v5.0.0-beta.0 release.
Note that we hope to release Redux Toolkit 2.0, Redux core 5.0, and React-Redux 9.0 by the start of December! (If we don't hit that, we'll aim for January, after the holidays.)
See the preview Redux Toolkit 2.0 + Redux core 5.0 Migration Guide for an overview of breaking changes in RTK 2.0 and Redux core.
npm install redux@next
yarn add redux@nextFull Changelog: v5.0.0-beta.0...v5.0.0-rc.0
…changes from the 5.0 alphas. This release has breaking changes from 4.x.
This beta release alters our TS types to add and use a new UnknownAction type where possible for better type safety, and includes all prior changes from the 5.0 alphas. This release has breaking changes from 4.x.
We recommend that users should prefer using Redux Toolkit for Redux development, and use the RTK 2.0 beta that depends on this core release, rather than using the Redux core library directly
npm i redux@next
yarn add redux@nextUnknownAction TypeThe Redux TS types have always exported an AnyAction type, which is defined to have {type: string} and treat any other field as any. This makes it easy to write uses like console.log(action.whatever), but unfortunately does not provide any meaningful type safety.
We now export an UnknownAction type, which treats all fields other than action.type as unknown. This encourages users to write type guards that check the action object and assert its specific TS type. Inside of those checks, you can access a field with better type safety.
UnknownAction is now the default any place in the Redux source that expects an action object.
AnyAction still exists for compatibility, but has been marked as deprecated.
Note that Redux Toolkit's action creators have a .match() method that acts as a useful type guard:
if (todoAdded.match(someUnknownAction)) {
// action is now typed as a PayloadAction<Todo>
}Summarizing changes from the earlier 5.0-alpha releases:
createStore deprecation tag portedisMinified checkSetReducer type accepts a PreloadedState genericaction and next are typed as unknownaction.type field must be a stringFull Changelog: v5.0.0-alpha.6...v5.0.0-beta.0
This is an alpha release for Redux 5.0, and has breaking changes . It changes store.dispatch to require that action.type must always be a string.
This is an alpha release for Redux 5.0, and has breaking changes. It changes store.dispatch to require that action.type must always be a string.
We've always specifically told our users that actions and state must be serializable, and that action.type should be a string. This is both to ensure that actions are serializable, and to help provide a readable action history in the Redux DevTools.
store.dispatch(action) now specifically enforces that action.type must be a string and will throw an error if not, in the same way it throws an error if the action is not a plain object.
In practice, this was already true 99.99% of the time and shouldn't have any effect on users (especially those using Redux Toolkit and createSlice), but there may be some legacy Redux codebases that opted to use Symbols as action types.
We've updated our supported TS version matrix to be TS 4.7 and higher.
Full Changelog: v5.0.0-alpha.5...v5.0.0-alpha.6
v5.0.0-alpha.6 Pre-release
Pre-release
Compare
This change does include some breaking changes, but overall should not have a huge impact on users upgrading in user-land:
This is an alpha release for Redux 5.0. This release has has breaking types changes.
npm i redux@alpha
yarn add redux@alphaReducer type and PreloadedState genericWe've made tweaks to the TS types to improve type safety and behavior. There are two big types changes in this alpha.
First, the Reducer type now has a PreloadedState possible generic:
type Reducer<S, A extends Action, PreloadedState = S> = (
state: S | PreloadedState | undefined,
action: A
) => SPer the explanation in #4491 :
Why the need for this change? When the store is first created by createStore, the initial state is set to whatever is passed as the preloadedState argument (or undefined if nothing is passed). That means that the first time that the reducer is called, it is called with the preloadedState. After the first call, the reducer is always passed the current state (which is S).
For most normal reducers, S | undefined accurately describes what can be passed in for the preloadedState. However the combineReducers function allows for a preloaded state of Partial<S> | undefined.
The solution is to have a separate generic that represents what the reducer accepts for its preloaded state. That way createStore can then use that generic for its preloadedState argument.
Previously, this was handled by a $CombinedState type, but that complicated things and led to some user-reported issues. This removes the need for $CombinedState altogether.
This change does include some breaking changes, but overall should not have a huge impact on users upgrading in user-land:
Reducer, ReducersMapObject, and createStore types/function take an additional PreloadedState generic which defaults to S.combineReducers are removed in favor of a single function definition that takes the ReducersMabObject as its generic parameter. Removing the overloads was necessary with these changes, since sometimes it was choosing the wrong overload.action and next are typed as unknownCurrently, the next parameter is typed as the D type parameter passed, and action is typed as theAction extracted from the dispatch type. Neither of these are a safe assumption:
next would be typed to have all of the dispatch extensions, including the ones earlier in the chain that would no longer apply.
next as the default Dispatch implemented by the base redux store, however this would cause next(action) to error (as we cannot promise action is actually an Action) - and it wouldn't account for any following middlewares that return anything other than the action they're given when they see a specific action.action is not necessarily a known action, it can be literally anything - for example a thunk would be a function with no .type property (so AnyAction would be inaccurate)We've changed next to be (action: unknown) => unknown (which is accurate, we have no idea what next expects or will return), and changes the action parameter to be unknown (which as above, is accurate).
Full Changelog: v5.0.0-alpha.4...v5.0.0-alpha.5
v5.0.0-alpha.5 Pre-release
Pre-release
Compare
This is an alpha release for Redux 5.0. This release has many changes to our build setup and published package contents, and has breaking changes .
This is an alpha release for Redux 5.0. This release has many changes to our build setup and published package contents, and has breaking changes.
npm i redux@alpha
yarn add redux@alphaThe 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.
Earlier alphas made changes to the package.json contents and published build artifacts in an attempt to get ESM+CJS compat working correctly, but those alphas had several varying compat issues.
We've set up a battery of example applications in the RTK repo that use a variety of build tools (currently CRA4, CRA5, Next 13, and Vite, Node CJS mode, and Node ESM mode), to verify that Redux and Redux Toolkit compile, import, and run correctly with both TS and various bundlers. We've also set up a check using a custom CLI wrapper around https://arethetypeswrong.github.io to check for potential packaging incompatibilities.
This release changes the names and contents of the published build artifacts, and the various exports/module/main fields in package.json to point to those.
The primary build artifact is now an ESM file, dist/redux.mjs. Most build tools should pick this up. There's also a CJS artifact, and a second copy of the ESM file named redux.legacy-esm.js to support Webpack 4 (which does not recognize the exports field in package.json).
As of this release, we think we have ESM+CJS compat working correctly, but we ask that the community try out the alphas in your apps and let us know of any compat problems!
Note: The one known potential issue is that TypeScript's new
moduleResolution: "node16"mode may see a mismatch between the ESM artifacts and the TS typedefs when imported in a Node CJS environment, and [that may allow hypothetically-incorrect import usage. (See ongoing discussion in https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/21 .) In practice, we think that probably won't be a concern, and we'll do further investigation before a final release.
We're now building the package using https://github.com/egoist/tsup . It looks like the output is effectively equivalent, but please let us know if there's any issues.
We also now include sourcemaps for the ESM and CJS artifacts.
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.
We do have a browser-ready ESM build artifact included at dist/redux.browser.mjs, which can be loaded via a script tag that points to that file on Unpkg.
If you have strong use cases for us continuing to include UMD build artifacts, please let us know!
Full Changelog: v5.0.0-alpha.2...v5.0.0-alpha.4
v5.0.0-alpha.4 Pre-release
Pre-release
Compare
Nothing published for this version
This is an alpha release for Redux 5.0. This release has types changes, an internal implementation tweak, and many changes to our build and test setup
This is an alpha release for Redux 5.0. This release has types changes, an internal implementation tweak, and many changes to our build and test setup.
The TS conversion in 2019 had made some changes to the definition of the StoreEnhancer TS type around replacing reducers. Some time later, we concluded that the enhancer types changes needed to be reverted, but that fell by the wayside. We've finally merged that reversion. This earlier type was never actually released publicly.
We also made an additional change to improve the typing of the next arg in enhancers.
The Redux store has always used an array to track listener callbacks, and used listeners.findIndex to remove listeners on unsubscribe. As we found in React-Redux, that can have perf issues when many listeners are unsubscribing at once.
In React-Redux, we fixed that with a more sophisticated linked list approach. Here, we've updated the listeners to be stored in a Map instead, which has better delete performance than an array.
In practice this shouldn't have any real effect, because React-Redux sets up a subscription in <Provider>, and all nested components subscribe to that. But, nice to fix it here as well.
We made numerous updates to our build tooling, including switching package management to Yarn 3, running tests directly from src locally instead of building first, actually running the TS typetests we'd added years ago, testing our types against a matrix of TS versions, and running tests in CI against a built copy of the library.
Full Changelog: v5.0.0-alpha.1...v5.0.0-alpha.2
v5.0.0-alpha.2 Pre-release
Pre-release
Compare
This is an alpha release for Redux 5.0. This release has breaking changes.
This is an alpha release for Redux 5.0. This release has breaking changes.
As part of the Redux Toolkit 2.0 alpha development work, we've migrated the redux core package definition to be a full {type: "module"} ESM package with an exports field (with CJS still included for compatibility purposes).
We've done local testing of the package, but we ask the community to try out this alpha in your own projects and report any breakages you find!
We've updated the build output in several ways:
./dist/, instead of separate top-level foldersWe've ported the @deprecated marker for createStore and added legacy_createStore from Redux 4.2.0. Please use Redux Toolkit's configureStore() instead, as well as the rest of Redux Toolkit's APIs.
The isMinified debug check has been removed.
The "valid reducer" check is done earlier to fix an edge case.
rollup.config.js by @xty in https://github.com/reduxjs/redux/pull/4311createStore deprecation and isMinified removal from 4.x branch by @markerikson in https://github.com/reduxjs/redux/pull/4473Full Changelog: https://github.com/reduxjs/redux/compare/v5.0.0-alpha.0...v5.0.0-alpha.1
v5.0.0-alpha.1 Pre-release
Pre-release
Compare
⚠️ This is an experimental alpha release. Things may break. If they do, let us know! ⚠️
⚠️ This is an experimental alpha release. Things may break. If they do, let us know! ⚠️
This release contains the TypeScript codebase conversion work we did in 2019, to let users check compatibility and see if this is suitable for publishing.
In 2019, we began a community-powered conversion of the Redux codebase to TypeScript. The original effort was discussed in #3500: Port to TypeScript, and the work was integrated in PR #3536: Convert to TypeScript.
However, the TS-converted code in master has sat around since then, unused and unpublished, due to concerns about possible compatibility issues with the existing ecosystem (as well as general inertia on our part).
Given the recent updates to Reselect and Redux Thunk, where we successfully published new minor builds that contained conversions to TS and significant rewrites/improvements to the TS types, it's worth publishing the current conversion as an alpha to give the community a chance to report any compatibility issues.
In theory, this should be almost identical in both runtime behavior and types to the recently released 4.1.2 build, but it's very likely that some of the changes may cause types issues.
Please try this out and let us know how it works! We're especially interested in any TS types compatibility issues you might see.
You can provide feedback in #4129: Evaluate current Redux TS port status to determine remaining work for a 5.0 release
This bugfix release removes the isMinified internal check to fix a compat issue with Expo. That check has added in early 2016, soon after Redux 3.0 wa
This bugfix release removes the isMinified internal check to fix a compat issue with Expo. That check has added in early 2016, soon after Redux 3.0 was released, at a time when it was still less common to use bundlers with proper production build settings. Today that check is irrelevant, so we've removed it.
Full Changelog: https://github.com/reduxjs/redux/compare/v4.2.0...v4.2.1
This release marks the original createStore API as @deprecated to encourage users to migrate to Redux Toolkit, and adds a new legacy_createStore API a…
This release marks the original createStore API as @deprecated to encourage users to migrate to Redux Toolkit, and adds a new legacy_createStore API as an alias without the deprecation warning.
Redux Toolkit (the @reduxjs/toolkit package) is the right way for Redux users to write Redux code today:
https://redux.js.org/introduction/why-rtk-is-redux-today
Unfortunately, many tutorials are still showing legacy "hand-written" Redux patterns, which result in a much worse experience for users. New learners going through a bootcamp or an outdated Udemy course just follow the examples they're being shown, don't know that RTK is the better and recommended approach, and don't even think to look at our docs.
Given that, the goal is to provide them with a visual indicator in their editor, like createStore . When users hover over the createStore import or function call, the doc tooltip recommends using configureStore from RTK instead, and points them to that docs page. We hope that new learners will see the strikethrough, read the tooltip, read the docs page, learn about RTK, and begin using it.
To be extremely clear:
WE ARE NOT GOING TO ACTUALLY REMOVE THE createStore API, AND ALL YOUR EXISTING CODE WILL STILL CONTINUE TO WORK AS-IS!
We are just marking createStore as "deprecated":
"the discouragement of use of some feature or practice, typically because it has been superseded or is no longer considered efficient or safe, without completely removing it or prohibiting its use"
For additional details, see the extensive discussion in https://github.com/reduxjs/redux/issues/4325 .
redux core package, or fully deprecate the entire redux package and rename it to @reduxjs/core. Unfortunately, those bring up too many complexities:
redux-starter-kit to @reduxjs/toolkit, and all of our docs and tutorials have pointed to it for the last three years. I don't want to put users through another whiplash package transition for no real benefitSo, this is the minimum possible approach we can take to reach out to users who otherwise would never know that they are following outdated patterns, while avoiding breaking running user code or having to completely rewrite our package and repo structure.
When a user imports createStore in their editor, they will see a visual strikethrough. Hovering over it will show a doc tooltip that encourages them to use configureStore from RTK, and points to an explanatory docs page:
Again, no broken code, and no runtime warnings.
If users do not want to see that strikethrough, they have three options:
configureStorelegacy_createStore API that is now exported, which is the exact same function but with no @deprecation tag. The simplest option is to do an aliased import rename:createStore as deprecated, and add legacy_createStore alias by @markerikson in https://github.com/reduxjs/redux/pull/4336Full Changelog: https://github.com/reduxjs/redux/compare/v4.1.2...v4.2.0
Nothing published for this version
This release fixes a small specific TS types issue where state types that had a nested unknown field inside would cause compilation failures when used
This release fixes a small specific TS types issue where state types that had a nested unknown field inside would cause compilation failures when used as the preloadedState argument.
Full Changelog: https://github.com/reduxjs/redux/compare/v4.1.1...v4.1.2
Just a small fix for Safari users in development mode.
Just a small fix for Safari users in development mode.
This release shrinks our bundle size via error message extraction, updates several error messages for clarity, and optimizes our list of runtime depen
This release shrinks our bundle size via error message extraction, updates several error messages for clarity, and optimizes our list of runtime dependencies.
Overall, version 4.1 shrinks from 2.6K min+gz to 1.6K min+gz thanks to these changes.
Be sure to check out the Redux Toolkit 1.6 alpha containing our new "RTK Query" data fetching APIs! It also includes Redux 4.1 as a dependency.
We now extract all of our error messages from production builds in order to save on bundle size, using a technique inspired from React's error code extraction. The error messages will still show as normal in development, but in production they will reference a specific numeric error code and provide a link to a Redux docs page that has the full error message.
An example of this is: https://redux.js.org/errors?code=5 , which shows the "can't subscribe while reducers are executing" error.
The error code extraction saves about 800 bytes out of a production build.
Thanks to @andrewmcgivery for doing all the hard work on implementing the error extraction!
We've also updated many of our error messages to provide additional details at runtime about what happened, especially runtime type checks such as "actions must be plain objects". They now provide a more specific type for the unexpected value, such as indicating promise or function:
expect(() => store.dispatch(() => {})).toThrow(
/the actual type was: 'function'/
)
expect(() => store.dispatch(new Date())).toThrow(
/the actual type was: 'date'/
)
We've updated the list of runtime dependencies for Redux:
symbol-observable polyfill. This shrinks bundle size by a few bytes,loose-envify dependency, which was only ever needed by Browserify users. If you still happen to be using Browserify, please review your build settings and see if you need to make any updates.@babel/runtime to extract some additional helpers out of our bundle. It's likely that your app already is pulling in those helpers anyway, so that removes some potential duplication.We've merged fixes for a couple edge cases in the 4.x TS typings related to state types.
This pre-release for 4.1.0 shrinks our bundle size via tooling updates, and updates several error messages for clarity. This is all the changes we pla
This pre-release for 4.1.0 shrinks our bundle size via tooling updates, and updates several error messages for clarity. This is all the changes we plan to have for 4.1, so if feedback looks good, we'll release 4.1.0 shortly.
The 4.1.0 release will have a more complete changelog, but summarizing:
symbol-observable polyfillloose-envify dependency@babel/runtime helpersWe've also updated the error messages to clarify what's happening, provide more details when runtime type checks fail, and link to relevant documentation.
https://github.com/reduxjs/redux/compare/v4.0.5...v4.1.0-alpha.0
This release includes a memory leak fix, and a fix for removing reducers with replaceReducer and combineReducers.
This release includes a memory leak fix, and a fix for removing reducers with replaceReducer and combineReducers.
There are also some TypeScript changes, which require version 3.5 or higher. This also removes our DeepPartial type, which wasn't intended to be a public API. If you need this type, you can find an equivalent of likely higher quality in the utility-types package.
Speaking of TypeScript, we are done with converting the code to TypeScript on master and are looking to get some TS improvements in before launching 5.0. If you're interested in helping, feel free to submit a PR with anything you'd like to contribute.
This is a republish of 4.0.3 with an updated version of Babel to fix #3468
This is a republish of 4.0.3 with an updated version of Babel to fix #3468
This is a quick revert of a change to our typings that broke compatibility. Apologies for the problems.
This is a quick revert of a change to our typings that broke compatibility. Apologies for the problems.
Also, if you are experiencing type errors related to [Symbol.observable], please ensure you have the same version of redux installed for all your dependencies with npm ls redux.
combineReducers' type parameters (#3467 by @timdorr)This is a very minor release with some nice improvements to our TypeScript type definitions. Enjoy!
This is a very minor release with some nice improvements to our TypeScript type definitions. Enjoy!
for in (#3371 by @pvorona)DeepPartial type (#3369 by @OliverJAsh)combineReducers (#3411 by @appden)A very minor release. We've upgraded to Babel 7 internally and now provide a .mjs file which you can import cleanly into browsers that support ES modu
A very minor release. We've upgraded to Babel 7 internally and now provide a .mjs file which you can import cleanly into browsers that support ES modules natively. Enjoy!
If you're a React user, this is going to be a lot like going from 15 to 16. Not a lot of user-facing changes, but some interesting improvements under
Redux 4 is here! 🎉
If you're a React user, this is going to be a lot like going from 15 to 16. Not a lot of user-facing changes, but some interesting improvements under the hood.
The major changes (#1342) are around our TypeScript definitions, bundled CommonJS and ES builds, throwing if you subscribe or getState from a reducer, and a bunch of other smaller things. The full changes are listed below.
Enjoy!
this (#2641 by @Parakleta)There haven't been any big complaints with the previous beta, so it's time to graduate to a release candidate. Please give this a try in your applicat
npm install redux@next
There haven't been any big complaints with the previous beta, so it's time to graduate to a release candidate. Please give this a try in your applications and let us know if you see any issues. If we're all clear, I'll get 4.0 released in the next week!
Another beta release to test our TypeScript typings. Feedback is greatly appreciated!
npm install redux@next
Another beta release to test our TypeScript typings. Feedback is greatly appreciated!
It's time to bump the major version on Redux! 🎉
It's time to bump the major version on Redux! 🎉
This is the first beta release of 4.0.0. Despite the version bump, the changes are relatively minor. Most of it was covered in the 4.0 tracking issue: #1342.
The largest amount of work was done with our Typescript definitions. They have been completely overhauled, so they should work better and take advantage of all the new stuff in TS 2.x.
The other big change is we are now bundling our CommonJS and ES builds like React has done recently. This means direct, private imports (import createStore from 'redux/lib/createStore') will no longer work. This ensures our modules are maintaining a consistent contract with your apps and that any reorganization we choose to do internally has no effect on your usage of Redux.
We've also tightened up some behavior quirks and dropped support for IE < 11. The vast majority of apps should require no changes. But we will run through a standard RC process to gradually release this out to the world and ensure no big headaches for everyone during the holiday season.
Enjoy!
this (#2641 by @Parakleta)Fixed the definition of 'Reducer' for TypeScript 2.4. (#2467 by @DanielRosenwasser)
This reverts the console.error on bindActionCreators() coming from #2279.
This reverts the console.error on bindActionCreators() coming from #2279.
While well-intentioned, when star importing all exports from a module (import * as actions from './actions'), transpilation by Babel defaults to adding a default and __esModule property to the import, which are not functions. While it can be disabled, this isn't common to do and leads to a lot of confusion. So, we're reverting the change.
Thanks for the feedback from everyone and the civility and healthy discourse on the issue!
Oh, hey! I didn't see you sitting there. You look bored. How about a Redux release to spice things up?
Oh, hey! I didn't see you sitting there. You look bored. How about a Redux release to spice things up?
Not a huge set of changes to report here. The biggest change, and the reason for the minor bump, is the UMD build is now done via Rollup. One big advantage is more readable code in the bundle. Rollup does "scope hoisting", which is a fancy term for putting every module at the top level of the file. Other than a surrounding IIFE, all of the code in Redux all lives together. You can compare the two here:
Rollup UMD build
vs
Webpack UMD build
There is also a cost savings of 30,811 vs 26,880 bytes, and 6,999 vs 5,995 bytes minified. Redux is already a small library, and this helps shave some extra bytes for our UMD users.
One thing to note is that Webpack has introduced it's own scope hoisting feature in 3.0 beta. So, this isn't intended as an indictment of Webpack. You should continue to use it in your own apps. The adage of "Webpack is for apps, Rollup is for libraries" definitely holds true. It still has a superior developer experience with hot module reloading and webpack-dev-server. But use whatever makes sense for your project, not just whatever we use. 😄
We're also looking at applying this to the NPM bundle. The main motivation is again more readable code in your bundles. Instead of transpilation oddities from Babel, you will end up with a single clean file, which should be easier to read through and debug. It's currently scheduled for the big, mythical 4.0 release and you can follow along in #2358
How's everyone doing? Enjoying your summer (or winter for the Southern Hemisphere folks)?
How's everyone doing? Enjoying your summer (or winter for the Southern Hemisphere folks)?
This is a bugfix release for Redux. We're working towards a 4.0 with more substantial changes. Please see #1342 to pitch in!
Dan also ported all the examples (except the universal one) in #1883 to use the excellent Create React App. This means the changes in #1800 have been lost. If you'd like to help out, we would love PRs on the examples to modernize and clean them up.
Enforces a newer version of symbol-observable that works in IE8
symbol-observable that works in IE8 (#1659)Fixes a regression introduced in 3.5.0 that caused dispatch to not be available while middleware is initializing. (#1644, #1647)
dispatch to not be available while middleware is initializing. (#1644, #1647)Adds interop with observable libraries
Adds official TypeScript definitions (#1413, #1526, #1537, #1545)
ES Modules build now uses the ES Modules build of Lodash. This makes vanilla Redux code include zero CommonJS interop for Rollup users.
Fixes jsnext:main to point to a Rollup-friendly ES Modules build in redux/es. It still depends on Lodash so you can’t use without rollup-plugin-common
jsnext:main to point to a Rollup-friendly ES Modules build in redux/es. It still depends on Lodash so you can’t use without rollup-plugin-commonjs, but importing individual functions like import { createStore } from 'redux' should now work, and you shouldn’t be getting an error when you use npm({ jsnext: true }) anymore due to a broken jsnext:main. (https://github.com/rackt/redux/pull/1369, https://github.com/rackt/redux/issues/1042, https://github.com/rackt/redux/pull/1327)Force Lodash to be >= 4.2.0 to avoid global issues that were fixed in it (#1346, #1349)
global issues that were fixed in it (#1346, #1349)isPlainObject that we use internally is now outsourced to Lodash 4.1 (#1339). Note that this does not mean we depend on Lodash itself. We only use a t
isPlainObject that we use internally is now outsourced to Lodash 4.1 (#1339). Note that this does not mean we depend on Lodash itself. We only use a tiny module from it. We will be able to reuse the same module in React Redux.Fix an issue with setInterval unavailable in certain environments
setInterval unavailable in certain environments (#1335)subscribe() now throws a descriptive error when the listener argument is not a function
subscribe() now throws a descriptive error when the listener argument is not a function (#1325)bindActionCreators() now ignores anything but functions on the input object (#1329)replaceReducer() now throws a meaningful error rather than crashes if argument is not a function (#1318, #1321)
replaceReducer() now throws a meaningful error rather than crashes if argument is not a function (#1318, #1321)Fixes false positive for the envification check in IE because it doesn’t support Function.name
Function.name (https://github.com/rackt/redux/issues/1311)Don’t crash when console or console.error is unavailable
console or console.error is unavailable (#1311)Adds loose-envify as a dependency to fix builds for Browserify users. (#1304 & #1306)
loose-envify as a dependency to fix builds for Browserify users. (#1304 & #1306)Fixes applyMiddleware() to forward the enhancer if you mix the old and the new styles of specifying enhancers—there is no point to doing this though.
applyMiddleware() to forward the enhancer if you mix the old and the new styles of specifying enhancers—there is no point to doing this though. (https://github.com/rackt/redux/pull/1302)For Browserify users, Redux should now be properly envified without extra configuration
createStore() now receives an enhancer such as applyMiddleware() as the last optional argument (#1294)You don’t have to change anything. However if you use store enhancers such as applyMiddleware() or Redux DevTools you might like that you can now express the same code in a more JavaScript-friendly way:
- const createStoreWithMiddleware = applyMiddleware(
- thunk,
- logger
- )(createStore)
- const store = createStoreWithMiddleware(
- rootReducer,
- initialState
- )
+ const store = createStore(
+ rootReducer,
+ initialState,
+ applyMiddleware(thunk, logger)
+ )
For multiple store enhancers you can still use compose() but in a similar more straightforward fashion:
- const finalCreateStore = compose(
- applyMiddleware(thunk, logger),
- DevTools.instrument()
- )(createStore)
- const store = finalCreateStore(reducer, initialState)
+ const store = createStore(
+ reducer,
+ initialState,
+ compose(
+ applyMiddleware(thunk, logger),
+ DevTools.instrument()
+ )
+ )
The second initialState argument stays optional so you can skip it when specifying the enhancer.
The old way of doing things still works, too. We’re just adding a nicer way to apply enhancers, that’s all.
Happy reducing!
This does not affect the UMD builds. This is also a warning and not a hard error so it isn't a breaking change.
compose() now aligns more closely with Underscore/Lodash behavior by allowing multiple arguments to be passed to the last function. This is not changing the existing behavior for the single argument call which has been the only possible use case before. (https://github.com/rackt/redux/issues/632#issuecomment-157298480, https://github.com/rackt/redux/pull/1050)combineReducers() now runs faster. (https://github.com/rackt/redux/pull/1118)process.env.NODE_ENV polyfill (which we require anyway) is set to 'production'. This does not affect the UMD builds. This is also a warning and not a hard error so it isn't a breaking change. (https://github.com/rackt/redux/issues/1029, https://github.com/rackt/redux/pull/1075)redux/lib/*.js. This is only true for top-level directory—we do not supporting reaching into redux/lib/utils, for example. To support this, we moved all top-level exports to be in redux/lib, for example, redux/lib/applyMiddleware.js. (https://github.com/rackt/redux/issues/1223, https://github.com/rackt/redux/pull/1224)Removes .babelrc in the compiled package because it is irrelevant (we ship ES5 code) and breaks React Native 0.16 and some consumers who use Babel 6 f
.babelrc in the compiled package because it is irrelevant (we ship ES5 code) and breaks React Native 0.16 and some consumers who use Babel 6 forgetting to exclude node_modules from transformations. (https://github.com/rackt/redux/issues/1033, https://github.com/rackt/redux/issues/1039, https://github.com/rackt/redux/issues/1127)Unsubscribing a store listener is now a no-op when called twice instead of a bug (#938, #939, b7031ce3acb23b6ecadbd977b1cfa32486447904)
combineReducers() now returns the same object if none of the child states have changed. (#853, #856)
combineReducers() now returns the same object if none of the child states have changed. (#853, #856)One of the problems v3.0.1 was intended to solve was not completely fixed in 3.0.1. This release amends that.
One of the problems v3.0.1 was intended to solve was not completely fixed in 3.0.1. This release amends that.
combineReducer() sanity check will be delayed until the first dispatch. This lets Redux DevTools correctly handle it and recover from the error. (#717, #761, #807, gaearon/redux-devtools#106, gaearon/redux-devtools#120)To enjoy this, you’ll need at least redux-devtools@2.1.4.
This release brings a few changes that, while aimed at making the developer experience better, should have no noticeable impact on your apps.
This release brings a few changes that, while aimed at making the developer experience better, should have no noticeable impact on your apps.
combineReducers() now checks the state shape on every invocation instead of just once. This makes it easy to discover issues like #715 where you post-process the state from combineReducers() and then wonder why something you added to it has disappeared after the next action. This change has no effect in production, and you’re unlikely to hit it in development either, as post-processing state from combineReducers() isn't a very common pattern. (#715, #720)combineReducers() as a sanity check has been moved from the combineReducers() call to the first reducer invocation. Technically the check is still performed during the combineReducers() call, but the error is only thrown after during the initial dispatch. (Usually that would correspond to the createStore()call.) This reason for this is that otherwise an error thrown inside a reducer used to blow up combineReducers() and thus the whole module definition, and hot reloading used to fail in this case instead of showing the error in Redux DevTools. With this change and a corresponding fix in Redux DevTools, an error thrown inside a reducer that was later wrapped in combineReducers() will be displayed correctly, and once you fix the error, it will hot reload. (#717, #761, https://github.com/gaearon/redux-devtools/issues/106, https://github.com/gaearon/redux-devtools/pull/120)combineReducers() as a sanity check now uses @@redux/PROBE_UNKNOWN_ACTION_ prefix in the action type. Previously, action type was a random string. The reason for this change is to make it easier for type-checking libraries like redux-tcomb ignore such actions. This change does not affect application developers: just like before, you should never attempt to handle @@redux/* actions directly in your code. (#792, #796)Happy reducing!
replaceReducer() is un-deprecated.
It was only needed because React Redux used it to magically allow reducer hot reloading. This magic used to cause problems (https://github.com/rackt/r
getReducer() is removed from Store public API (https://github.com/rackt/redux/pull/668)It was only needed because React Redux used it to magically allow reducer hot reloading. This magic used to cause problems (https://github.com/rackt/redux/issues/301, https://github.com/rackt/redux/issues/340), so we made the usage of replaceReducer() for hot reloading explicit (https://github.com/rackt/redux/pull/667).
It is likely that you never used getReducer(). However, if you used hot reloading of reducers, you'll need to add module.hot API calls to the place where you create the store. (Of course, assuming that you use Webpack.)
import { createStore } from 'redux';
import rootReducer from '../reducers/index';
export default function configureStore(initialState) {
return createStore(rootReducer, initialState);
}
import { createStore } from 'redux';
import rootReducer from '../reducers/index';
export default function configureStore(initialState) {
const store = createStore(rootReducer, initialState);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers/index');
store.replaceReducer(nextRootReducer);
});
}
return store;
}
This is more code, but what's happening is now explicit, and this also lets you do this right in index.js instead of creating a separate <Root> component. See https://github.com/rackt/redux/pull/667 for a migration example.
compose() now acts like a proper compose() (#669)This fixes the embarrassing mishap that compose() API was.
As suggested by @jlongster, now it is a proper compose() you'd find in Lodash or Underscore:
it('composes from right to left', () => {
const double = x => x * 2;
const square = x => x * x;
expect(compose(square)(5)).toBe(25);
expect(compose(square, double)(5)).toBe(100);
expect(compose(double, square, double)(5)).toBe(200);
});
In terms of usage, you just need to remove createStore from the chain, and add it as a function application instead.
const finalCreateStore = compose(
applyMiddleware(stuff),
devTools(),
somethingElse(),
createStore
);
const finalCreateStore = compose(
applyMiddleware(stuff),
devTools(),
somethingElse()
)(createStore);
process.env.NODE_ENV is required for CommonJS build (https://github.com/rackt/redux/pull/671)In 1.0.1, we temporarily removed the dependency on it to support React Native, but now that RN 0.10 is out with process.env.NODE_ENV polyfill, we again demand it to be defined. If you're not ready to use RN 0.10, or are in a different environment, either use a browser build, or shim it yourself.
…1.0.0-alpha -> 1.0.0-rc. 1.0 only has a single breaking change since 1.0.0-rc:
If you're migrating from 0.12, apply 0.12 -> 1.0.0-alpha migration first, and then 1.0.0-alpha -> 1.0.0-rc. 1.0 only has a single breaking change since 1.0.0-rc:
dispatch is attempted while reducer is executing, an error is thrown. Note that you can dispatch from lifecycle hooks just fine. It's only reducers that are not allowed to dispatch. (https://github.com/rackt/redux/issues/368)We moved under rackt Github org. This won't affect you, but the new official URL is https://github.com/rackt/redux. We did this because we share values, and we want to collaborate on creating better tools, libraries, documentation, and examples. Redux stays independent of React, but we will work closely with React Router community to figure out a better integration.
We have real docs now. There are a few missing pieces, but it's a terrific effort, so thanks to everybody who contributed in the past month to get this shipped. Thanks to Gitbook for providing great tooling, too.
There's been no shortage of great examples in Awesome Redux, but we're shipping two new built-in examples in 1.0. One of them is a very simple async application. Creating it is covered in async tutorial. Another example we ship is a “real-world” example. It's a port of somewhat well-known flux-react-router-example to Redux, and shows advanced techniques such as caching, data normalization, custom API middleware, and pagination. Hopefully this example will help answer some commonly asked questions.
bindActionCreators now can also accept a function as the first argument: https://github.com/rackt/redux/pull/352The work on Redux was funded by the community.
Meet some of the outstanding companies and individuals that made it possible:
NOTE: THIS IS A PRE-RELEASE WITH SOME BREAKING CHANGES. THE README IS NOT UPDATED TO ITS API, SEE EXAMPLES AND TESTS INSTEAD.
NOTE: THIS IS A PRE-RELEASE WITH SOME BREAKING CHANGES. THE README IS NOT UPDATED TO ITS API, SEE EXAMPLES AND TESTS INSTEAD.
Compatible example code: https://github.com/gaearon/redux/tree/v1.0.0-rc/examples Compatible test code: https://github.com/gaearon/redux/tree/v1.0.0-rc/test
Changes in these release build on top of changes in 1.0 alpha release, so check them out first.
This means that <Provider>, @provide, <Connector>, @connect are all there. This means you need to replace 'redux/react' with react-redux and redux/react-native with react-redux/native in your dependency tree, as well as add react-redux as an explicit dependency if you use React. For global builds, you'll get Redux from this library and ReactRedux from the other library. They should work together well.
Link: #230
import { createStore } from 'redux';
import { Provider } from 'redux/react'; // React
import { Provider } from 'redux/react-native'; // React Native
import { createStore } from 'redux';
import { Provider } from 'react-redux'; // React
import { Provider } from 'react-redux/native'; // React Native
createStore no longer implicitly combines reducersNow you have to use combineReducers explicitly to combine several reducer functions into a single reducer.
Link: #257
import { createStore } from 'redux';
import * as reducers from '../reducers';
const store = createStore(reducers);
import { createStore, combineReducers } from 'redux';
import * as reducers from '../reducers';
const reducer = combineReducers(reducers)
const store = createStore(reducer);
All middleware now accepts { getState, dispatch } as the first parameter. This means that, if your middleware already accepted ({ dispatch, getState }), you don't need to change anything, but otherwise you need to wrap your middleware into one more function.
Link: #213
// “Dumb” middleware
export function log(next) {
return (action) => {
console.log(action);
return next(action);
};
}
// “Smart” middleware
export function thunk({ dispatch, getState }) {
return next => action =>
typeof action === 'function' ?
action(dispatch, getState) :
next(action);
}
// “Dumb” middleware is wrapped in one more function
export function log(/* { dispatch, getState } */) {
return next => action => {
console.log(action);
return next(action);
};
}
// “Smart” middleware stays the same
export function thunk({ dispatch, getState }) {
return (next) => (action) =>
typeof action === 'function' ?
action(dispatch, getState) :
next(action);
}
createStore no longer accepts middlewareYou need to use a dedicated applyMiddleware(...middlewares) function that turns a vanilla createStore into a middleware-capable createStore.
Link: #213
import { createStore } from 'redux';
import * as reducers from '../reducers';
const store = createStore(
reducers,
initialState,
({ getState, dispatch }) => [thunk({ getState, dispatch }), logger]
);
import { createStore, combineReducers, applyMiddleware } from 'redux';
import * as reducers from '../reducers';
const reducer = combineReducers(reducers);
const finalCreateStore = applyMiddleware(thunk, logger)(createStore);
const store = finalCreateStore(reducer, initialState);
If you use “async action creator” form where an action creator returns a function with dispatch, getState => ... signature, now you need to add redux-thunk as a dependency and explicitly pass it to applyMiddleware.
Link: #256
import { createStore } from 'redux';
import * as reducers from '../reducers';
const store = createStore(reducers, initialState);
store.dispatch(incrementAsync());
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import * as reducers from '../reducers';
const reducer = combineReducers(reducers);
const finalCreateStore = applyMiddleware(thunk)(createStore);
const store = finalCreateStore(reducer, initialState);
store.dispatch(incrementAsync());
combineReducers now throws if you return undefined statePreviously, reducers could return undefined as a valid value. Unfortunately it's too easy to do this by mistake by putting an early return into a reducer, or by forgetting to specify a default case inside the switch statement. The new behavior is to throw in combineReducers if you return undefined while handling an action or initializing. If undefined is a valid state for your reducer, consider using null instead.
Links: #173, #191, #193, #197, #259
function toggle(state, action) {
switch (action.type) {
case SET_ON:
return true;
case SET_OFF:
return undefined;
}
}
function toggle(state = false, action) {
switch (action.type) {
case SET_ON:
return true;
case SET_OFF:
return false;
default:
return state;
}
}
combineReducers throws if you have no default caseHandling @@INIT action is an anti-pattern. It's internal to Redux, and you should never handle it directly. It is renamed to @@redux/INIT in Redux 1.0 RC. In addition, Redux now throws if your reducer does not return an initial state in response to a randomized action type.
If you used @@INIT action to return the initial state, you should instead return it when the state passed as the first argument is undefined, regardless of the action type. You should remove any reference to @@INIT action type from your code.
If you used @@INIT action to transform rehydrated state from server (for example, to turn plain objects into immutable maps), you need to do this by inspecting state instead. For example, see how redux-example fixed this problem.
Links: #186, #259
function counter(state, action) {
switch (action.type) {
case '@@INIT': // You could get away with this in alpha
return 0;
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
}
}
function immutable(state = Immutable.fromJS({}), action) {
switch (action.type) {
case '@@INIT': // You could get away with this in alpha
return Immutable.fromJS(state);
case DO_SOMETHING:
return state.merge(something);
}
}
function counter(state = 0, action) {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
default:
return state; // Will be probed by a random action
}
}
function immutable(state = {}, action) {
if (!Map.isMap(state) && !List.isList(state)) {
state = Immutable.fromJS(state);
}
switch (action.type) {
case DO_SOMETHING:
return state.merge(something);
default:
return state; // Will be probed by a random action
}
}
componentDidMountLink: #208
Link: #250
NOTE: THIS IS A PRE-RELEASE WITH SOME BREAKING CHANGES. THE README IS NOT UPDATED TO ITS API, SEE EXAMPLES AND TESTS INSTEAD.
NOTE: THIS IS A PRE-RELEASE WITH SOME BREAKING CHANGES. THE README IS NOT UPDATED TO ITS API, SEE EXAMPLES AND TESTS INSTEAD.
Compatible example code: https://github.com/gaearon/redux/tree/v1.0.0-alpha/examples Compatible test code: https://github.com/gaearon/redux/tree/v1.0.0-alpha/test
Full diff (includes changes to the examples, tests and implementation): https://github.com/rackt/redux/compare/v0.12.0...v1.0.0-alpha?diff=unified
composeStores</s> is now composeReducers.createDispatcher</s> is gone.createRedux</s> is now createStore.<Provider> now accepts store prop instead of <s>redux</s>.createStore signature is createStore(reducer: Function | Object, initialState: any, middlewares: Array | ({ getState, dispatch }) => Array).createStore is an object, composeReducers is automatically applied to it.getState function. The dispatch function lets you “recurse” the middleware chain and is useful for async: #113 (comment).dispatch provided by the default thunk middleware now walks the whole middleware chain.redux</s> to store.Your coding agent can read these notes before it upgrades. Set up the MCP server →