Skip to content

react-router@7.x breaks with React 18: "use is not exported from 'react'" #14020

@klaveriuzent

Description

@klaveriuzent

Reproduction

💥 Bug Description
When using react-router@7.7.0 with react@18.3.1, the build fails with the following error:

Attempted import error: 'use' is not exported from 'react'

📷
Image
Image

📌 Cause
This happens because react-router@7.x is using use() — a feature only available in upcoming React 19 — but the package’s peerDependencies still allow installing it alongside React 18, which leads to an import error during build.

System Info

System:
  OS: Windows 10 64-bit

Binaries:
  Node:  v22.13.0
  npm: v11.4.2

npmPackages:
  "react": "^18.3.1",
  "react-dom": "^18.3.1",
  "@types/react": "^19.1.8",
  "@types/react-dom": "^19.1.6",
  "typescript": "^4.9.5"

Used Package Manager

npm

Expected Behavior

Either: react-router@7.x should require React 19 explicitly
Or: react-router@7.x should not use use() if compatibility with React 18 is expected

Actual Behavior

When building with react-router@7.7.0 and react@18.3.1, the build fails with:
Attempted import error: 'use' is not exported from 'react'
This suggests react-router is using a feature not available in React 18.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions