Skip to content

Conversation

@camd
Copy link
Collaborator

@camd camd commented Sep 13, 2025

Build on top of #9124

React Router v6 Migration Summary

Overview

This PR migrates from react-router-dom v5.1.2 to v6.x and removes the deprecated connected-react-router library.

Key Changes

Dependencies

Package Before After
react-router-dom 5.1.2 6.x
connected-react-router 6.9.3 Removed
history 4.10.1 Removed (bundled in v6)

API Changes

v5 Pattern v6 Pattern
<Switch> <Routes>
<Route render={() => <Comp />} /> <Route element={<Comp />} />
<Redirect to="/path" /> <Route element={<Navigate to="/path" />} />
useHistory() / history.push() useNavigate() / navigate()
props.match.path Relative paths
ConnectedRouter BrowserRouter

Files Modified

Redux Store Changes:

  • ui/job-view/redux/configureStore.js - Removed router middleware and reducer

Router Updates:

  • ui/App.jsx - Replaced ConnectedRouter + Switch with BrowserRouter + Routes
  • ui/push-health/App.jsx - Updated to v6 routing patterns
  • ui/perfherder/App.jsx - Updated to v6 routing patterns
  • ui/intermittent-failures/App.jsx - Updated to v6 routing patterns

Navigation Refactoring:

  • ui/job-view/App.jsx - Replaced pushRoute with useNavigate
  • ui/job-view/headerbars/SecondaryNavBar.jsx - Replaced pushRoute with useNavigate
  • ui/job-view/pushes/PushActionMenu.jsx - Replaced pushRoute with useNavigate
  • ui/job-view/redux/stores/selectedJob.js - Uses window.history.pushState for URL updates
  • ui/job-view/redux/stores/pushes.js - Uses window.history.pushState for URL updates
  • ui/models/filter.js - Accepts navigate function instead of Redux pushRoute

New Utilities:

  • ui/helpers/router.js - Centralized navigation hooks and utilities

Why This Migration?

  1. Deprecation: connected-react-router is deprecated and unmaintained
  2. React 18 Compatibility: React Router v6 is designed for React 18
  3. Smaller Bundle: v6 has a significantly smaller footprint
  4. Better Patterns: Hooks-based API aligns with modern React practices

Testing

  • All existing unit tests pass
  • Job View navigation works correctly
  • URL parameters and query strings preserved
  • Push Health routes accessible
  • Perfherder routes and redirects work
  • Browser back/forward navigation works
  • Deep linking works for all routes

@camd camd self-assigned this Sep 13, 2025
@camd camd force-pushed the camd/react-deprecation-fixes branch from e9f41cb to 32cb302 Compare September 17, 2025 22:44
@Archaeopteryx
Copy link
Collaborator

Please rebase here when you find time.

@camd camd force-pushed the camd/react-deprecation-fixes branch 2 times, most recently from 2fb0bc7 to 8164177 Compare September 22, 2025 15:06
@camd camd force-pushed the camd/react-deprecation-fixes branch 3 times, most recently from 7861722 to 4385715 Compare December 7, 2025 00:18
@camd camd force-pushed the camd/react-deprecation-fixes branch from 4385715 to e01b69e Compare December 20, 2025 23:39
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 68.19512% with 326 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.13%. Comparing base (5d64caf) to head (e01b69e).
⚠️ Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
ui/job-view/pushes/Push.jsx 64.67% 72 Missing and 5 partials ⚠️
ui/job-view/pushes/FuzzyJobFinder.jsx 52.94% 31 Missing and 1 partial ⚠️
ui/hooks/useDebounce.js 0.00% 22 Missing and 2 partials ⚠️
ui/job-view/pushes/PushJobs.jsx 70.73% 10 Missing and 2 partials ⚠️
ui/intermittent-failures/DateRangePicker.jsx 0.00% 10 Missing ⚠️
ui/intermittent-failures/Layout.jsx 0.00% 10 Missing ⚠️
ui/shared/RevisionInformation.jsx 0.00% 9 Missing ⚠️
ui/job-view/pushes/PushHeader.jsx 76.47% 7 Missing and 1 partial ⚠️
ui/job-view/details/summary/SummaryPanel.jsx 0.00% 7 Missing ⚠️
ui/intermittent-failures/BugDetailsView.jsx 0.00% 5 Missing ⚠️
... and 61 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8971      +/-   ##
==========================================
+ Coverage   79.95%   81.13%   +1.18%     
==========================================
  Files         600      603       +3     
  Lines       32560    33712    +1152     
  Branches     3310     3248      -62     
==========================================
+ Hits        26032    27352    +1320     
+ Misses       6362     5988     -374     
- Partials      166      372     +206     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@camd camd changed the title fix: Front-end React deprecations Upgrade react-router and related to react-router-dom Dec 21, 2025
@camd camd changed the title Upgrade react-router and related to react-router-dom 5th: Upgrade react-router and related to react-router-dom Dec 21, 2025
@camd camd closed this Dec 21, 2025
@camd camd deleted the camd/react-deprecation-fixes branch December 21, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants