[Snyk] Upgrade react-redux from 7.2.1 to 8.0.2 #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was automatically created by Snyk using the credentials of a real user.
Snyk has created this PR to upgrade react-redux from 7.2.1 to 8.0.2.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
Warning: This is a major version upgrade, and may be a breaking change.
Release notes
Package name: react-redux
This patch release tweaks the behavior of
connect
to print a one-time warning when the obsoletepure
option is passed in, rather than throwing an error. This fixes crashes caused by libraries such asreact-beautiful-dnd
continuing to pass in that option (unnecessarily) to React-Redux v8.What's Changed
Full Changelog: v8.0.1...v8.0.2
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
Subscription
causesnoImplicitAny
error by @ vicrep in #1910Full Changelog: v8.0.0...v8.0.1
Read more
This release candidate updates our peer deps to accept all React versions with hooks (16.8+, 17+, and 18+), as well as React Native (0.59+). (The code already worked, but the peer deps needed to be updated to match behavior and install correctly.)
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.
What's Changed
peerDependencies
by @ kyletsang in #1893Full Changelog: v8.0.0-rc.0...v8.0.0-rc.1
This release candidate removes the
DefaultRootState
type left over from the@ types/react-redux
package. Additionally, we now have tests that exercise theserverState
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.
Changelog
Removal of the
DefaultRootState
typeThe
@ types/react-redux
package, which has always been maintained by the community, included aDefaultRootState
interface that was intended for use with TS's "module augmentation" capability. Bothconnect
anduseSelector
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
andAppDispatch
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 tounknown
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
DefaultRootState
type by @ markerikson in #1887serverState
behavior by @ markerikson in #1888Full Changelog: v8.0.0-beta.4...v8.0.0-rc.0
This beta release switches the default entry point to use the
useSyncExternalStore
shim for compatibility with React 16.8+, and switches to a"/next"
alternate entry point without the shim.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! We'd also like to add some additional tests around SSR behavior.
We would like to release v8 as final within the next couple weeks now that React 18 is available.
Changelog
useSyncExternalStore
Shim UsageReact 18 adds the new
useSyncExternalStore
API. In previous betas, the plan was that React-Redux v8 would have a hard requirement on React 18. As a fallback, the betas provided a"/compat"
entry point that included theuSES
"shim", a userland implementation from the React team that provided compatibility with earlier React versions back to 16.8. That adds a few hundred bytes to the bundle size, so we wanted to keep the default size smaller.However, React Native will not support React 18 until the "New Architecture" is done. So, release React-Redux v8 with a hard React 18 requirement would immediately start breaking RN usage.
After discussion with the React team, we've flipped the default behavior in v8. Now, the default entry point does rely on the
uSES
shim. This increases final bundle size slightly (about 600b minified compared to v7.x). However, this ensures that React-Redux v8 is compatible with React 16.8+/17 out of the box, enabling users to upgrade to v8 right away even if they aren't using React 18. It also ensures continued RN compatibility.For users who would like to strip out the shim, this release switches to having a
"/next"
entry point that directly importsuseSyncExternalStore
from React, with no shim. You can alias"react-redux": "react-redux/next"
in your bundler to use that instead.What's Changed
useSyncExternalStore
shim behavior and update React deps by @ markerikson in #1884Full Changelog: v8.0.0-beta.3...v8.0.0-beta.4
This beta release fixes a regression with unsubscribe performance in
useSelector
, and does some minor internal cleanup inconnect
.At this point, React-Redux v8 is likely feature-complete and stable. We still really want users to try this out and give us feedback before the final release! We'd also like to add some additional tests around SSR behavior.
The tentative plan is to do a final review of the code and behavior after React 18 goes final, then release React-Redux v8 final shortly after that.
Changelog
useSelector
Unsubscribe PerformanceIn 2019, we fixed a a reported issue with
useSelector
unsubscriptions showing quadratic performance, due to use of a singlelisteners
array in ourSubscription
class. The fix was to switch to using a linked list to track subscribers.When we reworked
useSelector
to useuseSyncExternalStore
for v8, we passedstore.subscribe
directly and stopped subscribing via aSubscription
instance, thinking that we might no longer needSubscription
any more. However,Subscription
is still used by<Provider>
, so it won't be removed from the bundle anyway, and the switch to usingstore.subscribe
regressed the unsubscription performance because it does still use alisteners
array as well.We've switched back to having
useSelector
subscribe to theSubscription
instance from<Provider>
, and verified that this re-resolves the unsubscription performance behavior. We've also added a perf test to ensure that we capture this intended behavior and don't accidentally regress on this again in the future.Internal Cleanup
We've removed a couple additional references to the removed
pure
option inconnect
, and tweaked some of the types to remove a legacy signature forProvider
that is no longer relevant.What's Changed
pure
removal by @ Andarist in #1859Full Changelog: v8.0.0-beta.2...v8.0.0-beta.3
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!
Huge thanks to @ Ephem for providing an SSR example to work with, and @ acdlite for the API idea.
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
Read more
Read more
Commit messages
Package name: react-redux
Compare
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information:
🧐 View latest project report
🛠 Adjust upgrade PR settings
🔕 Ignore this dependency or unsubscribe from future upgrade PRs