react-native-testing-library icon indicating copy to clipboard operation
react-native-testing-library copied to clipboard

Incompatible React versions: The "react" and "react-native-renderer"

Open pawel3ala opened this issue 2 months ago • 7 comments

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 

pawel3ala avatar Dec 08 '25 10:12 pawel3ala

Bump also react test renderer:

react-test-renderer: 19.1.2 => 19.1.2 

mdjastrzebski avatar Dec 08 '25 11:12 mdjastrzebski

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)

pawel3ala avatar Dec 08 '25 12:12 pawel3ala

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)

mdjastrzebski avatar Dec 08 '25 12:12 mdjastrzebski

Seems clear from the error that your RN requires React 19.1.0, also set RTR to 19.1.0

mdjastrzebski avatar Dec 08 '25 12:12 mdjastrzebski

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

pawel3ala avatar Dec 08 '25 13:12 pawel3ala

You can fix it today, just use React (&RTR) version as instructed by that error message from react

mdjastrzebski avatar Dec 08 '25 13:12 mdjastrzebski

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)

pawel3ala avatar Dec 08 '25 14:12 pawel3ala