v8.0.0-beta.2 #1856
markerikson
started this conversation in
General
v8.0.0-beta.2
#1856
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This beta release makes several fixes to the TypeScript types for v8, fixes several dev dependencies that were accidentally listed as
dependencies
, and adds initial React 18 SSR support.Changelog
TypeScript Fixes
The initial TS conversion effort ported a chunk of the typetests from the React-Redux v7 types in DefinitelyTyped. We've ported over the remainder of the typetests, which uncovered a few bugs and missing types (such as the
useStore
hook not being generic).Those issues are now fixed, and after some additional tweaks all of the typetests are now passing. This means that existing TS usage of React-Redux v7 should be able to work entirely as-is with v8.
React 18 SSR Support
The new React 18
useSyncExternalStore
hook accepts a function to supply the current state when called, which is normally the Reduxstore.getState
method. However, a mutable store like Redux could change before or during an initial hydration render (such as a manualstore.dispatch()
before callinghydrateRoot()
, or React components dispatching actions during the mount process). To avoid that,useSyncExternalStore
also requires that you provide agetServerSnapshot
function that can return a consistent single state value.uSES
will use that all the way through the initial hydration render, and then check to see if any further updates are needed based on the latest state after the hydration render is complete.The
Provider
component now accepts an optionalserverState
prop. If you're doing SSR, serialize your Redux store state on the server and pass that in toProvider
as<Provider store={store} serverState={window.initialServerState}>
, similar to how you would initialize a Redux store with that value.We've updated both
useSelector
andconnect
to use theserverState
value if it exists and pass that touseSyncExternalStore
. This has been only briefly tested so far, but it appears to correctly eliminate hydration mismatch warnings.We would really like more users to try this out and give us feedback!
Dependency Updates
React-Redux now expects React 18 RC as a peer dep.
Several test libraries were accidentally added as
dependencies
in the previous betas, so they would get installed in user projects as well. Those have been moved back todevDependencies
as intended.What's Changed
Full Changelog: v8.0.0-beta.1...v8.0.0-beta.2
This discussion was created from the release v8.0.0-beta.2.
Beta Was this translation helpful? Give feedback.
All reactions