npm react-redux 8.0.0-rc.0

latest releases: 9.1.2, 9.1.1, 9.1.0...
2 years ago

This release candidate removes the DefaultRootState type left over from the @types/react-redux package. Additionally, we now have tests that exercise the serverState SSR behavior added in a previous beta.

At this point, React-Redux v8 is feature-complete and stable. We still really want users to try this out and give us feedback before the final release! Barring any reported issues, we plan to release 8.0 as final within the next few days.


Removal of the DefaultRootState type

The @types/react-redux package, which has always been maintained by the community, included a DefaultRootState interface that was intended for use with TS's "module augmentation" capability. Both connect and useSelector used this as a fallback if no state generic was provided. When we migrated React-Redux to TS, we copied over all of the types from that package as a starting point.

However, the Redux team specifically considers use of a globally augmented state type to be an anti-pattern. Instead, we direct users to extract the RootState and AppDispatch types from the store setup, and create pre-typed versions of the React-Redux hooks for use in the app.

Now that React-Redux itself is written in TS, we've opted to remove the DefaultRootState type entirely. State generics now default to unknown instead.

Technically the module augmentation approach can still be done in userland, but we discourage this practice.

SSR Tests

We added a serverState prop to <Provider> in beta.2 to resolve hydration mismatch issues, but had only done some quick hands-on testing locally. We now have tests that cover that use case.

What's Changed

Full Changelog: v8.0.0-beta.4...v8.0.0-rc.0

Don't miss a new react-redux release

NewReleases is sending notifications on new releases.