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
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
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
useStorehook 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
useSyncExternalStorehook accepts a function to supply the current state when called, which is normally the Reduxstore.getStatemethod. 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,useSyncExternalStorealso requires that you provide agetServerSnapshotfunction that can return a consistent single state value.uSESwill 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
Providercomponent now accepts an optionalserverStateprop. If you're doing SSR, serialize your Redux store state on the server and pass that in toProvideras<Provider store={store} serverState={window.initialServerState}>, similar to how you would initialize a Redux store with that value.We've updated both
useSelectorandconnectto use theserverStatevalue 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
dependenciesin the previous betas, so they would get installed in user projects as well. Those have been moved back todevDependenciesas 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