ref: remove withSentryRouter HOC#115949
Merged
evanpurkhiser merged 1 commit intoMay 20, 2026
Merged
Conversation
Contributor
📊 Type Coverage Diff
🔍 3 new type safety issues introduced
This is informational only and does not block the PR. |
ryan953
approved these changes
May 20, 2026
`withSentryRouter` was a `withRouter`-style HOC that emulated the react-router 3 `WithRouterProps` interface (`location`, `params`, `router`, `routes`) and remapped `orgId` to the current customer domain. There are only five consumers, and none of them actually read `params.orgId` from the remap -- they just want the underlying router data. Migrate each consumer to the specific hook (or prop) it actually needs and delete the HOC: - `jsonForm`: function component. Drop the HOC, call `useLocation()` directly for the scroll-to-hash behaviour, and stop forwarding the legacy `location`/`params`/`router`/`routes` props to user `visible` callbacks -- no callback in the tree consumes them. - `dateRange`: class component. Take `routes: PlainRoute[]` as a prop (used only for `getRouteStringFromRoutes` in analytics) and inject it via a thin `WithRoutes` function wrapper that calls `useRoutes()`. - `releaseSeries`: class component. Take `location` and `navigate` as props. Replace `router.location.query.project` with `location.query.project` and `router.push(...)` with `navigate(...)`. Inject via a `WithRouter` wrapper around the existing `withOrganization(withApi(withTheme(...)))` stack. The spec drops the synthetic `router`/`routes`/`params`/`location` fixture overrides -- the hooks supply real values now. - `releaseSessionsChart`: class component that only reads `location`. Inject via a `WithLocation` wrapper. - `widgetCard`: function component. Drop the HOC entirely and call `useLocation()` directly alongside the existing `useNavigate` / `useOrganization` / `useParams` calls. Also drop the `no-restricted-imports` entry for `sentry/utils/withSentryRouter` from `eslint.config.ts` and delete `withSentryRouter.tsx` / `withSentryRouter.spec.tsx`. See getsentry/frontend-tsc#78
a995758 to
abc2f57
Compare
JonasBa
pushed a commit
that referenced
this pull request
May 21, 2026
`withSentryRouter` was a `withRouter`-style HOC that emulated the react-router 3 `WithRouterProps` interface (`location`, `params`, `router`, `routes`) and remapped `orgId` to the current customer domain. There are only five consumers, and none of them actually read `params.orgId` from the remap — they just want the underlying router data. Migrate each consumer to the specific hook (or prop) it actually needs and delete the HOC: - `jsonForm`: function component. Drop the HOC, call `useLocation()` directly for the scroll-to-hash behaviour, and stop forwarding the legacy `location`/`params`/`router`/`routes` props to user `visible` callbacks — no callback in the tree consumes them. - `dateRange`: class component. Take `routes: PlainRoute[]` as a prop (used only for `getRouteStringFromRoutes` in analytics) and inject it via a thin `WithRoutes` function wrapper that calls `useRoutes()`. - `releaseSeries`: class component. Take `location` and `navigate` as props. Replace `router.location.query.project` with `location.query.project` and `router.push(...)` with `navigate(...)`. Inject via a `WithRouter` wrapper around the existing `withOrganization(withApi(withTheme(...)))` stack. The spec drops the synthetic `router`/`routes`/`params`/`location` fixture overrides — the hooks supply real values now. - `releaseSessionsChart`: class component that only reads `location`. Inject via a `WithLocation` wrapper. - `widgetCard`: function component. Drop the HOC entirely and call `useLocation()` directly alongside the existing `useNavigate` / `useOrganization` / `useParams` calls. Also drop the `no-restricted-imports` entry for `sentry/utils/withSentryRouter` from `eslint.config.ts` and delete `withSentryRouter.tsx` / `withSentryRouter.spec.tsx`. Follow-up to #115945 (which removed `useRouter`) — this finishes off the last in-repo consumer of legacy router HOCs. See getsentry/frontend-tsc#78
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
withSentryRouterwas awithRouter-style HOC that emulated the react-router 3WithRouterPropsinterface (location,params,router,routes) and remappedorgIdto the current customer domain. There are only five consumers, and none of them actually readparams.orgIdfrom the remap — they just want the underlying router data.Migrate each consumer to the specific hook (or prop) it actually needs and delete the HOC:
jsonForm: function component. Drop the HOC, calluseLocation()directly for the scroll-to-hash behaviour, and stop forwarding the legacylocation/params/router/routesprops to uservisiblecallbacks — no callback in the tree consumes them.dateRange: class component. Takeroutes: PlainRoute[]as a prop (used only forgetRouteStringFromRoutesin analytics) and inject it via a thinWithRoutesfunction wrapper that callsuseRoutes().releaseSeries: class component. Takelocationandnavigateas props. Replacerouter.location.query.projectwithlocation.query.projectandrouter.push(...)withnavigate(...). Inject via aWithRouterwrapper around the existingwithOrganization(withApi(withTheme(...)))stack. The spec drops the syntheticrouter/routes/params/locationfixture overrides — the hooks supply real values now.releaseSessionsChart: class component that only readslocation. Inject via aWithLocationwrapper.widgetCard: function component. Drop the HOC entirely and calluseLocation()directly alongside the existinguseNavigate/useOrganization/useParamscalls.Also drop the
no-restricted-importsentry forsentry/utils/withSentryRouterfromeslint.config.tsand deletewithSentryRouter.tsx/withSentryRouter.spec.tsx.Follow-up to #115945 (which removed
useRouter) — this finishes off the last in-repo consumer of legacy router HOCs.See https://github.com/getsentry/frontend-tsc/issues/78