npm react-redux 8.0.0-beta.0

latest releases: 9.0.2, 9.0.1, 9.0.0...
2 years ago

This beta release adds a new 'react-redux/compat' entry point for use with React 16.9+ 17.x, re-enabling broader compatibility across React versions to make it easier to upgrade to React-Redux v8.

While there are no other changes since the previous alphas (and there's really been very minimal feedback reported on the alphas thus far), we believe the v8 pre-releases are stable enough to begin seriously evaluating them as upgrades in your apps. This also aligns with React 18 being upgraded to beta status and the useSyncExternalStore API stabilizing.

We would really appreciate users trying out this release with all compatible versions of React and reporting the results, even if it's just "yup, tried it and it works"! Please provide feedback in the linked discussion thread.

Overall, v8.0's major changes include:

  • Conversion of the codebase to TypeScript (no more @types/react-redux)
  • Use of React's new useSyncExternalStore API for React 18 compat
  • Removal of unused legacy APIs (connectAdvanced, the pure option for connect)
  • Modernization of build artifact compilation

For more details on those, see the v8.0.0-alpha.0 release notes.

Note: this release has a crash bug that is fixed in v8.0.0-beta.1 - please be sure to install the next tag or beta.1 specifically

npm i react-redux@next

yarn add react-redux@next


New "Compat" Entry point

In 8.0.0-alpha.0, we switched the internals of connect and useSelector to use the new useSyncExternalStore API from React. At the time, that was only available in the form of a "shim" package that worked with multiple React versions.

In 8.0.0-alpha.1, useSyncExternalStore had been added to React itself. The original plan was always to make React-Redux v8 have a hard dependency on React 18, and the shim adds about 750 bytes to bundle size, so we dropped use of the shim entirely.

After suggestions from the community, we've now added a new 'react-redux/compat' entry point that falls back to using the shim. This should enable React-Redux v8 to work correctly with earlier versions of React that support hooks (16.9+ and 17.x), as well as Preact (which does not appear to be implementing useSyncExternalStore at this time).

We've updated our test suite to run all tests against both React 18 and the standard entry point with no uSES shim, and React 17 and the "compat" entry point with the uSES shim, and all tests are passing.

The likely approach for using this would be to alias or override your build setup to redirect imports of 'react-redux' to the 'react-redux/compat' entry point instead.

What's Changed

  • Add a "compat" entry point that works with React 16.9+ and 17 by @markerikson in #1842


Don't miss a new react-redux release

NewReleases is sending notifications on new releases.