Skip to content

refactor(settings): Use react-router instead of reach/router#20755

Open
xlisachan wants to merge 2 commits into
mainfrom
PAY-3773
Open

refactor(settings): Use react-router instead of reach/router#20755
xlisachan wants to merge 2 commits into
mainfrom
PAY-3773

Conversation

@xlisachan

@xlisachan xlisachan commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This pull request

Package Changes

Route Definitions (App/index.tsx, Settings/index.tsx)

  • <Router basepath="/"><Routes> + <Route path="..." element={...} />
  • <Redirect from to noThrow /><Route path element={<Navigate to replace />} />
  • RouteComponentProps removed from all component signatures (~80+ files)
  • added at app root (index.tsx)

Navigation

  • useNavigate/useLocation/Link imports → react-router
  • Standalone navigate() from reach/router → useNavigate() hook or window.location.assign()
  • NavigateFn → NavigateFunction, NavigateOptions<{}> → NavigateOptions
  • navigateWithQuery() (non-hook) → uses a registered navigate ref from App; falls back to window.location.assign/replace before React mounts

Infrastructure

  • ReachRouterWindow → RouterWindow (deprecated alias kept)
  • ScrollToTop: removed default prop, uses useLocation from react-router
  • useWebRedirect: uses window.location.href instead of location.href

Test Infrastructure (mocks.tsx)

  • createHistory/createMemorySource/LocationProvider → createMemoryRouter/RouterProvider/MemoryRouter
  • renderWithRouter returns { ...renderResult, router } — tests use router.navigate() and
    router.state.location
  • jest.spyOn(ReactRouterDom, 'useNavigate') → jest.mock('react-router', ...)
  • IntersectionObserver mock added to setupTests.tsx
  • Tests needing router context wrapped in

Issue that this pull request solves

Closes: PAY-3773

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.

@xlisachan xlisachan force-pushed the PAY-3773 branch 10 times, most recently from 396e0ed to 9ebb165 Compare June 17, 2026 22:30
@xlisachan xlisachan marked this pull request as ready for review June 18, 2026 14:43
@xlisachan xlisachan requested a review from a team as a code owner June 18, 2026 14:43
@xlisachan xlisachan force-pushed the PAY-3773 branch 5 times, most recently from c777e5e to 41251a0 Compare June 23, 2026 20:53
@xlisachan xlisachan force-pushed the PAY-3773 branch 3 times, most recently from 2201f13 to 2cb958a Compare June 24, 2026 14:31
Because:
- The standalone navigateWithQuery replaced reach/router's navigate() with window.location.assign/replace, which silently drops options.state. The AppContext errorHandler passes isSessionAALUpgrade state through this path for the AAL upgrade flow.

This commit:
- Add registerNavigate to utilities.ts that stores a navigate ref
- Register the navigate function from App on mount via useEffect
- navigateWithQuery uses the registered function when available, falls back to window.location before React mounts
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.

1 participant