Skip to content

Commit

Permalink
Update react-router.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome committed Sep 19, 2024
1 parent 21bd22c commit 6df67b6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ You can instrument [`createMemoryRouter`](https://reactrouter.com/en/main/router

### Custom Error Boundaries

When using `react-router`, errors thrown inside route elements will only be re-thrown in **development mode**. In production, these errors won't be surfaced unless manually captured. If you **don't** have a custom error boundary in place, `react-router` will create a default one that "swallows" all errors.
When using `react-router`, errors thrown inside route elements will only be re-thrown in **development mode** while using [`strict mode`](https://react.dev/reference/react/StrictMode). In production, these errors won't be surfaced unless manually captured. If you **don't** have a custom error boundary in place, `react-router` will create a default one that "swallows" all errors.

<Note>
Note, that this only applies to render method and lifecycle errors since React doesn't need error boundaries to handle errors in event handlers.
Expand Down Expand Up @@ -119,7 +119,9 @@ import * as Sentry from "@sentry/react";
export function YourCustomRootErrorBoundary() {
const error = useRouteError() as Error;

Sentry.captureException(error);
React.useEffect(() => {
Sentry.captureException(error);
}, [error]);

return (
<div>
Expand Down

0 comments on commit 6df67b6

Please sign in to comment.