Skip to content

Conversation

@camd
Copy link
Collaborator

@camd camd commented Jan 4, 2026

Upgrade to React Router v7 and create comprehensive upgrade plan

React Router v7 Migration:

  • Update react-router-dom to [email protected]
  • Update imports in 32 source files and 21 test files
  • Remove v7 future flags from BrowserRouter (no longer needed)
  • Add TextEncoder/TextDecoder polyfills to test setup

Planning Document:

  • Replace react-19-upgrade-plan.md with post-react19-upgrade-plan.md
  • Add the following phases:
    • Phase 1: React Router v7 Migration - ✅ Completed
    • Phase 2: Replace Inactive/Problematic Dependencies - react-lazylog, react-table-6, react-highlight-words, react-linkify, react-hot-keys
    • Phase 3: Routine Dependency Updates - MUI, build tools, testing libraries, minor version bumps
    • Phase 4: Major Version Upgrades - Font Awesome 7, Fuse.js 7, query-string 9, Jest 30, fetch-mock 12
    • Phase 5: Codebase Modernization - Convert 57 class components to functional (by area: job-view → shared → push-health → intermittent-failures → infra-compare → perfherder)
    • Phase 6: API Type Safety - OpenAPI codegen for Treeherder API, Zod for external APIs (Bugzilla) and form validation
    • Future: TypeScript Migration - Full TypeScript adoption after Phases 5 & 6 complete
      58 files changed, including the new comprehensive planning document at docs/post-react19-upgrade-plan.md.

camd and others added 30 commits December 21, 2025 11:53
The withView HOC is a class component that expected location and history
props to be passed automatically by React Router. In React Router v6,
these are no longer passed - you must use hooks instead.

This caused the error: "Cannot read properties of undefined (reading 'state')"
at line 21: this.default = this.props.location.state || defaultState;

Fix by creating a ViewWithRouter wrapper component that:
- Uses useLocation() and useNavigate() hooks
- Injects location and navigate as props to the class component
- Creates a history-like object with push/replace for backwards compatibility

Also adds unit tests to verify the intermittent-failures routes render
correctly with React Router v6.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace the withView class-based Higher Order Component with a modern
useIntermittentFailuresData custom hook. This eliminates the need for
the ViewWithRouter wrapper and makes the code more readable and testable.

Changes:
- Create useIntermittentFailuresData.jsx custom hook that encapsulates
  all state management and data fetching logic
- Update MainView.jsx to use the hook directly instead of withView HOC
- Update BugDetailsView.jsx to use the hook directly instead of withView HOC
- Remove View.jsx (the old class-based HOC)
- Update tests to work with the new hook-based implementation

The hook uses:
- useState for state management (replacing this.state)
- useEffect for lifecycle (replacing componentDidMount)
- useCallback for memoized functions
- useRef for pending update tracking (replacing setState callbacks)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add Zustand dependency
- Create notificationStore.js with notify, clearNotification,
  clearExpiredNotifications, clearAllOnScreenNotifications actions
- Update 17 components to use Zustand notifications instead of Redux
- Export standalone notify function for use outside React components
- Remove notify from Redux connect() mapDispatchToProps in all components

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Create Zustand pinnedJobsStore with all pinned jobs functionality
- Export standalone functions for use outside React components
- Migrate 7 components to use the new store:
  - PinBoard.jsx: Add Zustand subscription for class component reactivity
  - KeyboardShortcuts.jsx: Use standalone pinJob, unPinAll functions
  - DetailsPanel.jsx: Use setPinBoardVisible from Zustand
  - PushList.jsx: Use usePinnedJobsStore hook
  - PushHeader.jsx: Use standalone pinJobs function
  - PushJobs.jsx: Use standalone togglePinJob function
  - FiltersMenu.jsx: Use standalone pinJobs function
- Remove pinnedJobs state from Redux mapStateToProps in all components

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Create selectedJobStore.js with Zustand implementation
- Migrate job selection, clearing, and URL-based selection
- Update all components to use Zustand selectedJobStore:
  - KeyboardShortcuts.jsx: Remove Redux connect, use store directly
  - DetailsPanel.jsx: Subscribe to Zustand, track selectedJob in state
  - PinBoard.jsx: Import setSelectedJob from Zustand store
  - TabsPanel.jsx: Use Zustand hooks for selectedJob
  - ActiveFilters.jsx: Use Zustand selectedJobStore
  - FiltersMenu.jsx: Use Zustand hooks
  - PushHeader.jsx: Import from Zustand store
  - PushJobs.jsx: Remove Redux connect, use memo only
  - PushList.jsx: Use Zustand for selectedJob

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Create comprehensive pushStore.js with:
- Nested jobs structure within pushes (jobs stored as push.jobs)
- Derived getters: getJobById, getJobByTaskRun, getPushJobs
- Actions: fetchPushes, pollPushes, updateRange, updatePushJobs
- Pre-calculated unclassified counts per push
- jobMap kept for compatibility during migration

Migrate all components from Redux connect to Zustand:
- PushList, Push, PushHeader, PushLoadErrors, PushActionMenu
- DetailsPanel, PinBoard, ActionBar, AnnotationsTab
- PerformanceTab, PerfData, SideBySide
- SecondaryNavBar, ActiveFilters
- CustomJobActions, BugFiler, InternalIssueFiler
- App.jsx (updated imports, removed useDispatch)

Class component pattern used: Zustand subscription in
componentDidMount/componentWillUnmount with state initialization
from usePushStore.getState()

All components now use Zustand instead of Redux for:
- pushList, jobMap, decisionTaskMap, bugSummaryMap
- loadingPushes, jobsLoaded
- allUnclassifiedFailureCount, filteredUnclassifiedFailureCount
- revisionTips

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add v7_startTransition and v7_relativeSplatPath future flags to
  BrowserRouter to eliminate deprecation warnings and prepare for
  React Router v7 migration
- Update react-19-upgrade-plan.md with verified dependency compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document decision to replace react-helmet with React 19 native document
metadata support in a follow-up PR after the React 19 upgrade.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Upgrade react and react-dom from 18.3.1 to 19.2.3
- Move @types/react and @types/react-dom to devDependencies with ^19.0.0
- Fix test_data_modal_test.jsx: reset mock for each test to handle React 19's
  stricter state batching behavior

All 421 tests pass, build succeeds, lint passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
React 19 has built-in support for <title>, <meta>, and <link> tags that
automatically hoist to <head> when rendered anywhere in the component tree.

Updated files:
- ui/intermittent-failures/BugDetailsView.jsx
- ui/push-health/Health.jsx
- ui/push-health/MyPushes.jsx
- ui/shared/ComparePageTitle.jsx

Removed react-helmet dependency from package.json.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Mark React 19 upgrade as completed (18.3.1 → 19.2.3)
- Mark react-helmet replacement as completed
- Add replacement options for react-highlight-words:
  - Recommend keeping as-is (works at runtime)
  - Include custom implementation pattern if needed
- Add replacement options for react-table-6:
  - TanStack Table v8 (headless, official successor)
  - Material React Table (TanStack + MUI)
  - Mantine React Table (TanStack + Mantine)
  - AG Grid (most features)
  - Recommend keeping as-is for now

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@camd camd self-assigned this Jan 4, 2026
@camd camd requested review from Archaeopteryx and jmaher January 4, 2026 17:31
@codecov-commenter
Copy link

codecov-commenter commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 69.23571% with 479 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.37%. Comparing base (a82c683) to head (8d04f9e).

Files with missing lines Patch % Lines
ui/job-view/pushes/Push.jsx 66.66% 72 Missing and 5 partials ⚠️
ui/job-view/headerbars/ActiveFilters.jsx 7.46% 61 Missing and 1 partial ⚠️
ui/job-view/App.jsx 74.33% 43 Missing and 5 partials ⚠️
...ermittent-failures/useIntermittentFailuresData.jsx 66.93% 36 Missing and 5 partials ⚠️
ui/job-view/pushes/FuzzyJobFinder.jsx 54.28% 31 Missing and 1 partial ⚠️
ui/hooks/useDebounce.js 0.00% 22 Missing and 2 partials ⚠️
ui/job-view/details/summary/ActionBar.jsx 27.58% 21 Missing ⚠️
ui/job-view/headerbars/NotificationsMenu.jsx 40.90% 13 Missing ⚠️
ui/helpers/router.js 38.88% 11 Missing ⚠️
ui/job-view/headerbars/SecondaryNavBar.jsx 87.91% 10 Missing and 1 partial ⚠️
... and 34 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9143      +/-   ##
==========================================
+ Coverage   80.01%   81.37%   +1.35%     
==========================================
  Files         601      604       +3     
  Lines       32715    34024    +1309     
  Branches     3314     3265      -49     
==========================================
+ Hits        26178    27687    +1509     
+ Misses       6371     5954     -417     
- Partials      166      383     +217     

☔ 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.

React Router v7 Migration:
- Update react-router-dom to [email protected]
- Update imports in 32 source files and 21 test files
- Remove v7 future flags from BrowserRouter (no longer needed)
- Add TextEncoder/TextDecoder polyfills to test setup

Planning Document:
- Replace react-19-upgrade-plan.md with post-react19-upgrade-plan.md
- Add Phase 5: Class → Functional component migration (57 components)
- Add Phase 6: API Type Safety (OpenAPI codegen + Zod)
- Document PropTypes strategy (keep for docs, no Zod for props)
- Add detailed migration order by feature area

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@camd camd force-pushed the camd/react-router-7 branch from 9a2e889 to 8d04f9e Compare January 4, 2026 18:01
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.

3 participants