discussions-and-proposals icon indicating copy to clipboard operation
discussions-and-proposals copied to clipboard

Be less strict in the react / react-native-renderer version check

Open c100k opened this issue 2 months ago • 0 comments

Introduction

Discussion based on the following issue : https://github.com/facebook/react-native/issues/54772. Since @rickhanlonii asked to avoid burrying the answer, I'm starting a discussion here.

TL;DR : Is there a way to be less strict in the react version check ?

Details

The React version check is very strict in ReactNativeRenderer-dev.js.

if ("19.1.0" !== isomorphicReactPackageVersion)
  throw Error(
    'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n  - react:                  ' +
      (isomorphicReactPackageVersion +
        "\n  - react-native-renderer:  19.1.0\nLearn more: https://react.dev/warnings/version-mismatch")
  );

Does someone know why ? I'm pretty sure there are very good technical reasons but I couldn't find a legitimate source explaining why.

The strictness of this check leads to the issue linked above. I understand that having to bump the React version urgently like this week is - hopefully - very rare, though. I also understand that there are other ways to mitigate without bumping React.

But this also leads to a deterioration of the DX on a day to day basis. Indeed, when you define the version as ^19.1.0, package managers and tools like dependabot or renovate will usually bump the version to the latest patch/minor. In a monorepo setup, this broke the mobile apps a couple of times, often silently.

The solution is to pin the version : 19.1.0. But this is a little weird as if we forget or are not careful, the version will never be updated by the tools mentioned above.

Discussion points

  • What are the reasons to check the exact version and not just the major.minor ?
  • Based on these reasons, is there a way to address them ?
  • Overall, is it possible to be more flexible (e.g. /^19\.1(\.|$)/.test(isomorphicReactPackageVersion) ?)

c100k avatar Dec 06 '25 11:12 c100k