Skip to content

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

@c100k

Description

@c100k

Introduction

Discussion based on the following issue : facebook/react-native#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) ?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions