From 9d0396ef3b98811c7600c4f1fef687f8e7f9e3e9 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 3 Sep 2026 14:41:05 +0200 Subject: [PATCH] docs(react): Add JSDoc to `withSentryRouting` The HOC is the only routing wrapper in the package without a doc comment, so nothing tells users it targets React Router v4/v5 only, that the wrapped Route must be rendered inside a Switch, or that v6+ should use wrapReactRouterRouting. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01MQRr9S6B2FYBKa9bMWHSxk --- packages/react/src/reactrouter.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/react/src/reactrouter.tsx b/packages/react/src/reactrouter.tsx index eddcd89ef386..2110d4835cf0 100644 --- a/packages/react/src/reactrouter.tsx +++ b/packages/react/src/reactrouter.tsx @@ -228,6 +228,22 @@ function computeRootMatch(pathname: string): Match { return { path: '/', url: '/', params: {}, isExact: pathname === '/' }; } +/** + * A higher-order component that adds Sentry routing instrumentation to a React Router v4 or v5 `Route` component. + * When the wrapped `Route` matches, the active pageload/navigation span is renamed to the parameterized route path. + * + * The wrapped `Route` must be rendered inside a `Switch`, since the match is read from the `computedMatch` prop + * that only `Switch` passes down. For React Router v6 and later, use `wrapReactRouterRouting` instead. + * + * @example + * ```jsx + * const SentryRoute = Sentry.withSentryRouting(Route); + * + * + * + * + * ``` + */ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */ export function withSentryRouting

, R extends React.ComponentType

>(Route: R): R { const componentDisplayName = Route.displayName || Route.name;