Incompatible React versions: The "react" and "react-native-renderer"
Describe the bug
There is a fairly new vulnerability on React 19.1.0
Suggested solution is to bump up React from 19.0.1 to 19.1.2
and that's exactly what I did.
At the moment, when I run npm run test all my component tests fail due to:
Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:
- react: 19.1.2
- react-native-renderer: 19.1.0
Learn more: https://react.dev/warnings/version-mismatch
Steps to Reproduce
Just run any unit test
Screenshots
Versions
npmPackages:
@testing-library/react-native: ^13.3.3 => 13.3.3
react: 19.1.2 => 19.1.2
react-native: ^0.81.3 => 0.81.5
Bump also react test renderer:
react-test-renderer: 19.1.2 => 19.1.2
I do have:
"react-test-renderer": "19.1.2",
same outcome
react-native-testing-library complains about react-native-renderer not react-test-renderer (not sure if that is relevant thou)
It's not RNTL complaining but rather react itself. Check if you have matching React and RN versions, they have different numbering but each RN version requires a certain version of React, then make sure your RTR matches your React version (this time same version number)
Seems clear from the error that your RN requires React 19.1.0, also set RTR to 19.1.0
hmm.. I took the very last version of react-native --- 0.82.1 and still got the same error
I can see that there is a RC version of react-native which is about to be released. Hopefully it will fix my issue
@mdjastrzebski thanks for helping me out narrowing the problem
You can fix it today, just use React (&RTR) version as instructed by that error message from react
just to be clear; I have
"dependencies": {
"react": "19.1.2", // bumped from 19.1.0
"react-dom": "19.1.2", // bumped from 19.1.0
"react-native": "^0.81.3", // latest version
},
"devDependencies": {
"@testing-library/react-native": "^13.3.3",
"react-test-renderer": "19.1.2", // bumped from 19.1.0
},
and still getting the same error
when I run test I have error complaining about react-native-renderer (not react-test-renderer)