Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump react-redux from 7.2.6 to 8.0.1 #92

Merged
merged 2 commits into from May 24, 2022

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github May 18, 2022

Bumps react-redux from 7.2.6 to 8.0.1.

Release notes

Sourced from react-redux's releases.

v8.0.1

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

Full Changelog: reduxjs/react-redux@v8.0.0...v8.0.1

v8.0.0

This major version release updates useSelector, connect, and <Provider> for compatibility with React 18, rewrites the React-Redux codebase to TypeScript (obsoleting use of @types/react-redux), modernizes build output, and removes the deprecated connectAdvanced API and the pure option for connect.

npm i react-redux@latest

yarn add react-redux@latest

Overview, Compatibility, and Migration

Our public API is still the same ( <Provider>, connect and useSelector/useDispatch), but we've updated the internals to use the new useSyncExternalStore hook from React. React-Redux v8 is still compatible with all versions of React that have hooks (16.8+, 17.x, and 18.x; React Native 0.59+), and should just work out of the box.

In most cases, it's very likely that the only change you will need to make is bumping the package version to "react-redux": "^8.0".

If you are using the rarely-used connectAdvanced API, you will need to rewrite your code to avoid that, likely by using the hooks API instead. Similarly, the pure option for connect has been removed.

If you are using Typescript, React-Redux is now written in TS and includes its own types. You should remove any dependencies on @types/react-redux.

While not directly tied to React-Redux, note that the recently updated @types/react@18 major version has changed component definitions to remove having children as a prop by default. This causes errors if you have multiple copies of @types/react in your project. To fix this, tell your package manager to resolve @types/react to a single version. Details:

[React issue #24304: React 18 types broken since release](facebook/react#24304)

Additionally, please see the React post on How to Ugprade to React 18 for details on how to migrate existing apps to correctly use React 18 and take advantage of its new features.

Changelog

React 18 Compatibility

React-Redux now requires the new useSyncExternalStore API in React 18. By default, it uses the "shim" package which backfills that API in earlier React versions, so React-Redux v8 is compatible with all React versions that have hooks (16.8+, and React Native 0.59+) as its acceptable peer dependencies.

We'd especially like to thank the React team for their extensive support and cooperation during the useSyncExternalStore development effort. They specifically designed useSyncExternalStore to support the needs and use cases of React-Redux, and we used React-Redux v8 as a testbed for how useSyncExternalStore would behave and what it needed to cover. This in turn helped ensure that useSyncExternalStore would be useful and work correctly for other libraries in the ecosystem as well.

Our performance benchmarks show parity with React-Redux v7.2.5 for both connect and useSelector, so we do not anticipate any meaningful performance regressions.

useSyncExternalStore and Bundling

The useSyncExternalStore shim is imported directly in the main entry point, so it's always included in bundles even if you're using React 18. This adds roughly 600 bytes minified to your bundle size.

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added the dependencies Pull requests that update a dependency file label May 18, 2022
@nx-cloud
Copy link

nx-cloud bot commented May 18, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit a65a009. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@bdebon
Copy link
Contributor

bdebon commented May 23, 2022

This PR was failling because of typescript typing with the useDispatch. Until now we were using useDispatch<any> or useDispatch. The first one was definitely not good because of the any and the second was not typped at all and this is what was causing this pr to fail. Maybe that the typing control is stronger with this new version.
In any case things had to be dealt. useDispatch must be typed correctly.
According to this page:
https://react-redux.js.org/using-react-redux/usage-with-typescript

We can override the type for RootState and AppDispatch. Overriding RootState is gonna solve a lot of time because up until now we were force to override it everytime we were using a useSelector.
AppDispatch is also gonna allow us to remove the useDispatch and finally having it typed correctly.
The only problem, it creates circular dependencies.
CleanShot 2022-05-23 at 10 55 43@2x

BUT: According to this stack overflow answer by the main maintainer of Redux Toolkit:

Type-only circular references are fine. The TS compiler will resolve those at compile time. In particular, it's normal to have a slice file export its reducer, import the reducer into the store setup, define the RootState type based on that slice, and then re-import the RootState type back into a slice file.

Which is an insane news for us because we were trying to avoid at all cost every possible circular dependencies but in this case, this one is accepted. Later in the answer you can read:

Circular imports are only a potential issue when runtime behavior is involved, such as two slices depending on each other's actions.
Unfortunately, the ESLint rule for catching circular dependencies can't tell that what's being imported is just a type, as far as I know.

This PR then contain all these fixes. Furthermore, I unfortunately had to add some any in the onboarding files because some things are done very differently that everywhere else in the project here and I don't have time to investigate this part.

dependabot bot and others added 2 commits May 23, 2022 11:59
Bumps [react-redux](https://github.com/reduxjs/react-redux) from 7.2.6 to 8.0.1.
- [Release notes](https://github.com/reduxjs/react-redux/releases)
- [Changelog](https://github.com/reduxjs/react-redux/blob/master/CHANGELOG.md)
- [Commits](reduxjs/react-redux@v7.2.6...v8.0.1)

---
updated-dependencies:
- dependency-name: react-redux
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@bdebon bdebon force-pushed the dependabot/npm_and_yarn/react-redux-8.0.1 branch from 9b6ff74 to a65a009 Compare May 23, 2022 10:08
@bdebon
Copy link
Contributor

bdebon commented May 23, 2022

@WilliamTraoreee , @gromon42 I ask both your opinion here because it's a major discovery about the cyclic dependency. Please read my previous comment before checking the changes. Let's talk about this during our v3 sync tonight

@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github May 23, 2022

A newer version of react-redux exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

@bdebon
Copy link
Contributor

bdebon commented May 24, 2022

Eslint is saying there is a circular dependency between domains-application and store-data
CleanShot 2022-05-24 at 14 36 48@2x

But when I generate the dep graph, I don't see any circular dependency between domains-application and store-data
CleanShot 2022-05-24 at 14 35 19@2x

Which seems to validate what markerikson is saying on the stack overflow issue, that the transpiler knows how to deal with circular dependency when it's type only.
With that proof, I'm gonna merge this branch.

@bdebon bdebon merged commit c175fe7 into staging May 24, 2022
@bdebon bdebon deleted the dependabot/npm_and_yarn/react-redux-8.0.1 branch May 24, 2022 12:43
@bdebon
Copy link
Contributor

bdebon commented Jun 22, 2022

🎉 This PR is included in version 1.0.0-staging.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@bdebon
Copy link
Contributor

bdebon commented Nov 17, 2022

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file released on @staging released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant