Skip to content

refactor(onboarding): replace deprecated useRouter with useLocation and useNavigate#115453

Open
cursor[bot] wants to merge 2 commits into
masterfrom
cursor/legacy-routing-patterns-0b7f
Open

refactor(onboarding): replace deprecated useRouter with useLocation and useNavigate#115453
cursor[bot] wants to merge 2 commits into
masterfrom
cursor/legacy-routing-patterns-0b7f

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 12, 2026

Replace the deprecated useRouter() hook (a react-router 3 shim) with the modern useLocation() and useNavigate() hooks in platformOptionsControl.tsx.

Changes

  • useUrlPlatformOptions hook: replaced useRouter().location with useLocation() directly
  • PlatformOptionsControl component: replaced useRouter().replace() with useNavigate() + {replace: true} option
  • Added proper type narrowing for query parameters (typeof queryValue === 'string' guard) since useLocation() returns properly typed query values (QueryParamValue<string>) instead of any

This is part of the ongoing effort to remove react-router 3 shim code tracked in the React Router cleanup Notion database.

Verification

  • TypeScript typecheck passes cleanly
  • ESLint passes
  • All 3 existing tests pass (renders default state, updates URL on change, triggers onChange callback)

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Open in Web View Automation 

cursoragent and others added 2 commits May 12, 2026 22:37
…te in platformOptionsControl

Replace the legacy useRouter() hook from react-router 3 shim with the modern
useLocation() and useNavigate() hooks:

- useUrlPlatformOptions: router.location → useLocation()
- PlatformOptionsControl: router.replace() → navigate({...}, {replace: true})

Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
With useLocation() instead of useRouter(), query values are properly typed as
QueryParamValue<string> (string | string[] | null | undefined) instead of 'any'.
Add typeof string guard and non-null assertion for proper type safety.

Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 12, 2026
@ryan953 ryan953 marked this pull request as ready for review May 12, 2026 22:52
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.50% 93.50% ±0%
Typed 135,336 135,341 🟢 +5
Untyped 9,411 9,409 🟢 -2
🔍 1 new type safety issue introduced

Non-null assertions (!) (1 new)

File Line Detail
static/app/components/onboarding/platformOptionsControl.tsx 36 values[0]!

This is informational only and does not block the PR.

@ryan953 ryan953 requested review from a team, evanpurkhiser and shashjar May 12, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant