v8.0.1
This release fixes an incorrect internal import of our Subscription
type, which was causing TS compilation errors in some user projects. We've also listed @types/react-dom
as an optional peerDep. There are no runtime changes in this release.
What's Changed
Full Changelog: https://github.com/reduxjs/react-redux/compare/v8.0.0...v8.0.1
v8.0.0
This major version release updates useSelector
, connect
, and <Provider>
for compatibility with React 18, rewrites the React-Redux codebase to TypeScript (obsoleting use of @types/react-redux
), modernizes build output, and removes the deprecated connectAdvanced
API and the pure
option for connect
.
npm i react-redux@latest
yarn add react-redux@latest
Overview, Compatibility, and Migration
Our public API is still the same ( <Provider>
, connect
and useSelector/useDispatch
), but we've updated the internals to use the new useSyncExternalStore
hook from React. React-Redux v8 is still compatible with all versions of React that have hooks (16.8+, 17.x, and 18.x; React Native 0.59+), and should just work out of the box.
In most cases, it's very likely that the only change you will need to make is bumping the package version to "react-redux": "^8.0"
.
If you are using the rarely-used connectAdvanced
API, you will need to rewrite your code to avoid that, likely by using the hooks API instead. Similarly, the pure
option for connect
has been removed.
If you are using Typescript, React-Redux is now written in TS and includes its own types. You should remove any dependencies on @types/react-redux
.
While not directly tied to React-Redux, note that the recently updated @types/react@18
major version has changed component definitions to remove having children
as a prop by default. This causes errors if you have multiple copies of @types/react
in your project. To fix this, tell your package manager to resolve @types/react
to a single version. Details:
[React issue #24304: React 18 types broken since release](facebook/react#24304)
Additionally, please see the React post on How to Ugprade to React 18 for details on how to migrate existing apps to correctly use React 18 and take advantage of its new features.
Changelog
React 18 Compatibility
React-Redux now requires the new useSyncExternalStore
API in React 18. By default, it uses the "shim" package which backfills that API in earlier React versions, so React-Redux v8 is compatible with all React versions that have hooks (16.8+, and React Native 0.59+) as its acceptable peer dependencies.
We'd especially like to thank the React team for their extensive support and cooperation during the useSyncExternalStore
development effort. They specifically designed useSyncExternalStore
to support the needs and use cases of React-Redux, and we used React-Redux v8 as a testbed for how useSyncExternalStore
would behave and what it needed to cover. This in turn helped ensure that useSyncExternalStore
would be useful and work correctly for other libraries in the ecosystem as well.
Our performance benchmarks show parity with React-Redux v7.2.5 for both connect
and useSelector
, so we do not anticipate any meaningful performance regressions.
useSyncExternalStore
and Bundling
The useSyncExternalStore
shim is imported directly in the main entry point, so it's always included in bundles even if you're using React 18. This adds roughly 600 bytes minified to your bundle size.
... (truncated)