Skip to content

v6.0.0-beta.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@timdorr timdorr released this 06 Nov 21:47
· 834 commits to master since this release
7496b91

🎉 This is our first big release supporting the new React Context API! No more blocked updates!

As such, we now require React 16.4 or higher. Make sure to update your version when updating to this release.

This work has been mostly lead by @cellog and @markerikson, with special guest appearances by yours truly and a whole cast of helpful reviewers. While we've had a lot of eyes on this refactor, we need more! Please test this out in your applications and let us know if there are big performance or feature regressions.

npm install react-redux@next

Note: 6.0.0-beta.2 is now on npm. This fixes an incorrect peer dependency for React 16.6 in beta.1.

Breaking Changes

Known major breaking changes:

  • The withRef option to connect has been replaced with forwardRef. If {forwardRef : true} has been passed to connect, adding a ref to the connected wrapper component will actually return the instance of the wrapped component. (Known issue: Redux Form currently relies on withRef.)
  • Passing store as a prop to a connected component is no longer supported. Instead, you may pass a custom context={MyContext} prop to both <Provider> and <ConnectedComponent>. You may also pass {context : MyContext} as an option to connect.

Other Behavior Changes

Any library that attempts to access the store instance out of legacy context will break, because we now put the store state into a <Context.Provider> instead. Examples of this include connected-react-router and react-redux-subspace. (The current implementation does also put the store itself into that same context. While accessing the store in context is not part of our public API, we will still try to make it possible for other libraries to access it, with the understanding that this could break at any time.)

Also, there is a behavior change around dispatching actions in constructors / componentWillMount. Previously, dispatching in a parent component's constructor would cause its children to immediately use the updated state as they mounted, because each component read from the store individually. In version 6, all components read the same current store state value from context, which means the tree will be consistent and not have "tearing". This is an improvement overall, but there may be applications that relied on the existing behavior.

Other than those issues, this should be API-compatible with the existing version 5.x line.

Changes