Skip to content

Commit 1e3ba37

Browse files
authored
fix(remix): Move hook checks inside the wrapper component. (#5371)
`withSentryRouteTracing` is called on `root.tsx` which runs before `entry.client.tsx` (where `Sentry.init` for browser is called and `remixRouterInstrumentation` is assigned). The check if the provided hooks are available was failing silently, and causing `withSentryRouteTracing` to early return the `App` unwrapped. This PR ensures that validation runs on the client side, after `entry.client.tsx`.
1 parent 2f01844 commit 1e3ba37

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/remix/src/performance/client.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ export function remixRouterInstrumentation(useEffect: UseEffect, useLocation: Us
8181
* To enable pageload/navigation tracing on every route.
8282
*/
8383
export function withSentryRouteTracing<P extends Record<string, unknown>, R extends React.FC<P>>(OrigApp: R): R {
84-
// Early return when any of the required functions is not available.
85-
if (!_useEffect || !_useLocation || !_useMatches || !_customStartTransaction) {
86-
__DEBUG_BUILD__ && logger.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
87-
88-
// @ts-ignore Setting more specific React Component typing for `R` generic above
89-
// will break advanced type inference done by react router params
90-
return OrigApp;
91-
}
92-
9384
const SentryRoot: React.FC<P> = (props: P) => {
85+
// Early return when any of the required functions is not available.
86+
if (!_useEffect || !_useLocation || !_useMatches || !_customStartTransaction) {
87+
__DEBUG_BUILD__ &&
88+
logger.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
89+
90+
// @ts-ignore Setting more specific React Component typing for `R` generic above
91+
// will break advanced type inference done by react router params
92+
return <OrigApp {...props} />;
93+
}
9494
let isBaseLocation: boolean = false;
9595

9696
const location = _useLocation();

0 commit comments

Comments
 (0)