reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
https://redux-toolkit.js.org
MIT License
10.74k stars 1.18k forks source link

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

Closed joshuarichards001 closed 3 months ago

joshuarichards001 commented 3 months ago

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/toolkit@2.2.7
npm ERR! Found: react@19.0.0-rc-a7d1240c-20240731
npm ERR! node_modules/react
npm ERR!   react@"19.0.0-rc-a7d1240c-20240731" from the root project
npm ERR!   peer react@"*" from react-canvas-confetti@2.0.7
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/toolkit@2.2.7
npm ERR! node_modules/@reduxjs/toolkit
npm ERR!   @reduxjs/toolkit@"^2.2.7" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.3.1
npm ERR! node_modules/react
npm ERR!   peerOptional react@"^16.9.0 || ^17.0.0 || ^18" from @reduxjs/toolkit@2.2.7
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 commented 3 months ago

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 commented 3 months ago

To put it another way:

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 commented 3 months ago

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
heshamabdelazim commented 3 weeks ago

I have same problem right now, and searching for answers. but answers not found. Apparently, I will use react 18 as we were before.

phryneas commented 3 weeks ago

Yes, React 19 still has not been released, so we cannot make any claims about being compatible with it.