Skip to content

Commit 7442128

Browse files
committed
feat(remix): Wrap root with ErrorBoundary.
1 parent 815801a commit 7442128

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

packages/remix/README.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Sentry.init({
5757
});
5858
```
5959

60-
Also, wrap your Remix root, with Sentry's `ErrorBoundary` component to catch React component errors, and `withSentryRouteTracing` to get parameterized router transactions.
60+
Also, wrap your Remix root with `withSentryRouteTracing` to catch React component errors and to get parameterized router transactions.
6161

6262
```ts
6363
// root.tsx
@@ -71,24 +71,22 @@ import {
7171
ScrollRestoration,
7272
} from "@remix-run/react";
7373

74-
import { ErrorBoundary, withSentryRouteTracing } from "@sentry/remix";
74+
import { withSentryRouteTracing } from "@sentry/remix";
7575

7676
function App() {
7777
return (
78-
<ErrorBoundary>
79-
<html>
80-
<head>
81-
<Meta />
82-
<Links />
83-
</head>
84-
<body>
85-
<Outlet />
86-
<ScrollRestoration />
87-
<Scripts />
88-
<LiveReload />
89-
</body>
90-
</html>
91-
</ErrorBoundary>
78+
<html>
79+
<head>
80+
<Meta />
81+
<Links />
82+
</head>
83+
<body>
84+
<Outlet />
85+
<ScrollRestoration />
86+
<Scripts />
87+
<LiveReload />
88+
</body>
89+
</html>
9290
);
9391
}
9492

packages/remix/src/performance/client.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { withErrorBoundary } from '@sentry/react';
12
import { Transaction, TransactionContext } from '@sentry/types';
23
import { getGlobalObject, logger } from '@sentry/utils';
34
import * as React from 'react';
@@ -87,7 +88,8 @@ export function withSentryRouteTracing<P extends Record<string, unknown>, R exte
8788

8889
// @ts-ignore Setting more specific React Component typing for `R` generic above
8990
// will break advanced type inference done by react router params
90-
return OrigApp;
91+
return withErrorBoundary(OrigApp);
92+
// Note: Error boundary doesn't depend on any of these functions, so we can return the wrapped component.
9193
}
9294

9395
const SentryRoot: React.FC<P> = (props: P) => {
@@ -135,5 +137,5 @@ export function withSentryRouteTracing<P extends Record<string, unknown>, R exte
135137

136138
// @ts-ignore Setting more specific React Component typing for `R` generic above
137139
// will break advanced type inference done by react router params
138-
return SentryRoot;
140+
return withErrorBoundary(SentryRoot);
139141
}

0 commit comments

Comments
 (0)