Skip to content

fix: warn when multiple React Router versions are loaded - #15369

Open
Turtle-Hwan wants to merge 2 commits into
remix-run:mainfrom
Turtle-Hwan:fix/15356-version-mismatch-warning
Open

fix: warn when multiple React Router versions are loaded#15369
Turtle-Hwan wants to merge 2 commits into
remix-run:mainfrom
Turtle-Hwan:fix/15356-version-mismatch-warning

Conversation

@Turtle-Hwan

Copy link
Copy Markdown

Fixes #15356.

Problem

Loading react-router and react-router-dom versions that resolve to different
react-router module instances creates separate React contexts. Hooks can
report a generic missing-router error, while <Outlet> can render nothing
without explaining the version mismatch.

Changes

  • Reuse the existing window.__reactRouterVersion marker to track versions
    seen in the browser
  • Warn once in development when more than one version is detected
  • Check from context-consuming hooks so both module load orders and the silent
    <Outlet> path are covered
  • Preserve existing SSR and production behavior
  • Add regression tests for earlier, later, and matching version registration

The patch intentionally does not attempt to bridge incompatible React contexts.
The warning tells users to align their react-router and react-router-dom
versions.

Validation

  • pnpm build
  • pnpm test packages/react-router/ --runInBand
    • 110 test suites passed
    • 2,214 tests passed
    • 15 tests skipped
  • pnpm typecheck
  • pnpm lint — 0 errors; existing warnings only
  • pnpm changes:validate
  • Prettier check for changed files
  • Browser reproduction in Declarative and Data modes for useNavigate and
    <Outlet>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mismatched major versions (react-router v8 & react-router-dom v7) cause silent runtime failure without dev warning

2 participants