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

Redux Toolkit not compatible with React 19? Could not resolve dependency. #4540

Closed
joshuarichards001 opened this issue Aug 1, 2024 · 3 comments

Comments

@joshuarichards001
Copy link

Hey there, I'm trying out the React Compiler on the React 19 beta but when running npm install on the latest @reduxjs/toolkit I'm getting Could not resolve dependency errors. Below is the full error, is this a known problem?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @reduxjs/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"19.0.0-rc-a7d1240c-20240731" from the root project
npm ERR!   peer react@"*" from [email protected]
npm ERR!   node_modules/react-canvas-confetti
npm ERR!     react-canvas-confetti@"^2.0.7" from the root project
npm ERR!   1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional react@"^16.9.0 || ^17.0.0 || ^18" from @reduxjs/[email protected]
npm ERR! node_modules/@reduxjs/toolkit
npm ERR!   @reduxjs/toolkit@"^2.2.7" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peerOptional react@"^16.9.0 || ^17.0.0 || ^18" from @reduxjs/[email protected]
npm ERR!   node_modules/@reduxjs/toolkit
npm ERR!     @reduxjs/toolkit@"^2.2.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
@phryneas
Copy link
Member

phryneas commented Aug 1, 2024

React 19 is not released yet.
With a pre-release version you are the beta tester for the whole ecosystem and will probably have to override this in your package.json.

There's no reason that react-redux wouldn't work with React 19, but before React 19 has been released and we tested it with it we can't guarantee that it will work.
Even if it worked with a release candidate now, there's no guarantee that between now and the final React 19 release, something wouldn't get broken.

@markerikson
Copy link
Collaborator

To put it another way:

  • React-Redux v9 should work fine with React 19
  • RTK Query's React integration will also continue to work fine
  • But React 19 isn't final yet, so we haven't published any releases that say React 19 is an acceptable peer dependency
  • And NPM is notoriously picky and errors when there aren't valid peer deps

So, either use NPM's options to override the installation behavior, or use a better package manager that doesn't yell at you like this :)

@aryaemami59
Copy link
Contributor

Just as a side note I have working PRs migrating to React 19. They will most likely sit in draft until after the stable release of React 19, but they should circumvent the peer dependency issues for the time being.

For Redux-Toolkit:

npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/436d29c1/@reduxjs/toolkit

For React-Redux:

npm install https://pkg.csb.dev/reduxjs/react-redux/commit/3271037e/react-redux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants