Skip to content

Commit a5ff0ca

Browse files
committed
PR feedback
1 parent 8584284 commit a5ff0ca

File tree

2 files changed

+24
-23
lines changed
  • docs/platforms/javascript/guides/react/features/react-router

2 files changed

+24
-23
lines changed

docs/platforms/javascript/guides/react/features/react-router/v6.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: React Router v6
3-
description: "Learn about Sentry's React Router v6 integration."
3+
description: "Learn how to instrument your React Router v6 application with Sentry."
44
sidebar_order: 20
55
---
66

7-
_React Router v6 support is included in the `@sentry/react` package since version `7`._
7+
Apply the following setup steps based on your routing method and create a [custom error boundary](#custom-error-boundaries) to make sure Sentry automatically captures rendering errors.
88

9-
### Usage with `createBrowserRouter` or `createMemoryRouter`
9+
## Usage with `createBrowserRouter` or `createMemoryRouter`
1010

11-
To instrument your React Router, update to `Sentry.reactRouterV6BrowserTracingIntegration` within `Sentry.init` and provide the required React hooks and router functions. Then, wrap the router instance created by `createBrowserRouter` or `createMemoryRouter` with one of the following functions:
11+
To instrument your React Router, update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV6BrowserTracingIntegration` within `Sentry.init` and provide the required React hooks and router functions. Then, wrap the router instance created by `createBrowserRouter` or `createMemoryRouter` with one of the following functions:
1212

1313
- Use `Sentry.wrapCreateBrowserRouterV6` for [`createBrowserRouter`](https://reactrouter.com/en/main/routers/create-browser-router) and [`createHashRouter`](https://reactrouter.com/en/main/routers/create-hash-router)
1414
- Use `Sentry.wrapCreateMemoryRouterV6` for [`createMemoryRouter`](https://reactrouter.com/en/main/routers/create-memory-router) (introduced in SDK version `8.50.0`)
@@ -47,9 +47,9 @@ const router = sentryCreateBrowserRouter([
4747
]);
4848
```
4949

50-
### Usage With `<Routes />` Component
50+
## Usage With `<Routes />` Component
5151

52-
If you're using the `<Routes />` component to define your routes, update to `Sentry.reactRouterV6BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, wrap `<Routes />` using `Sentry.withSentryReactRouterV6Routing`. This creates a higher order component, which will enable Sentry to reach your router context. You can also use `Sentry.withSentryReactRouterV6Routing` for Routes inside `BrowserRouter`, `MemoryRouter`, and `HashRouter` components.
52+
If you're using the `<Routes />` component to define your routes, update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV6BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, wrap `<Routes />` using `Sentry.withSentryReactRouterV6Routing`. This creates a higher order component, which will enable Sentry to reach your router context. You can also use `Sentry.withSentryReactRouterV6Routing` for routes inside `BrowserRouter`, `MemoryRouter`, and `HashRouter` components.
5353

5454
```javascript {3-11, 18-24, 29, 33-35}
5555
import React from "react";
@@ -91,13 +91,13 @@ ReactDOM.render(
9191
);
9292
```
9393

94-
This wrapping is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
94+
This wrapper is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
9595

96-
### Usage With `useRoutes` Hook
96+
## Usage With `useRoutes` Hook
9797

9898
_Available in `@sentry/react` version `7.12.1` and above._
9999

100-
If you specify your route definitions as an object to the [`useRoutes` hook](https://reactrouter.com/en/main/hooks/use-routes), update to `Sentry.reactRouterV6BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, use `Sentry.wrapUseRoutesV6` to create a patched `useRoutes` hook that instruments your routes with Sentry.
100+
If you specify your route definitions as an object to the [`useRoutes` hook](https://reactrouter.com/en/main/hooks/use-routes), update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV6BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, use `Sentry.wrapUseRoutesV6` to create a patched `useRoutes` hook that instruments your routes with Sentry.
101101

102102
<Alert level="warning" title="Important">
103103
Call `wrapUseRoutesV6` outside of a React component, as in the example below. We also recommend that you assign the wrapped hook to a variable starting with `use`, as per [React's documentation](https://react.dev/learn/reusing-logic-with-custom-hooks#hook-names-always-start-with-use).
@@ -148,7 +148,7 @@ ReactDOM.render(
148148

149149
Now, Sentry should generate `pageload`/`navigation` transactions with parameterized transaction names (for example, `/teams/:teamid/user/:userid`), where applicable. This is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
150150

151-
### Custom Error Boundaries
151+
## Custom Error Boundaries
152152

153153
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.
154154

@@ -199,7 +199,7 @@ export function YourCustomRootErrorBoundary() {
199199

200200
```
201201

202-
## Next Steps:
202+
## Next Steps
203203

204204
- [Return to **Getting Started**](../../)
205205
- [Return to the main integrations page](../)

docs/platforms/javascript/guides/react/features/react-router/v7.mdx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
22
title: React Router v7 (library mode)
3-
description: "Learn about Sentry's React Router v7 integration."
3+
description: "Learn how to instrument your React Router v7 application with Sentry."
44
sidebar_order: 10
55
---
66

77
<Alert level="info" title="Looking for framework mode?">
88
React Router v7 (framework mode) is currently in experimental Alpha, check out
99
the docs [here](/platforms/javascript/guides/react-router/).
1010
</Alert>
11+
Apply the following setup steps based on your routing method and create a
12+
[custom error boundary](#custom-error-boundaries) to make sure Sentry
13+
automatically captures rendering errors.
1114

12-
_React Router v7 (library mode) support is included in the `@sentry/react` package since version `8.42.0`._
15+
## Usage with `createBrowserRouter` or `createMemoryRouter`
1316

14-
### Usage with `createBrowserRouter` or `createMemoryRouter`
15-
16-
To instrument your React Router, update to `Sentry.reactRouterV7BrowserTracingIntegration` within `Sentry.init` and provide the required React hooks and router functions. Then, wrap the router instance created by `createBrowserRouter` or `createMemoryRouter` with one of the following functions:
17+
To instrument your React Router, update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV7BrowserTracingIntegration` within `Sentry.init` and provide the required React hooks and router functions. Then, wrap the router instance created by `createBrowserRouter` or `createMemoryRouter` with one of the following functions:
1718

1819
- Use `Sentry.wrapCreateBrowserRouterV7` for [`createBrowserRouter`](https://reactrouter.com/en/main/routers/create-browser-router) and [`createHashRouter`](https://reactrouter.com/en/main/routers/create-hash-router)
1920
- Use `Sentry.wrapCreateMemoryRouterV7` for [`createMemoryRouter`](https://reactrouter.com/en/main/routers/create-memory-router) (introduced in SDK version `8.50.0`)
@@ -52,9 +53,9 @@ const router = sentryCreateBrowserRouter([
5253
]);
5354
```
5455

55-
### Usage With `<Routes />` Component
56+
## Usage With `<Routes />` Component
5657

57-
If you're using the `<Routes />` component to define your routes, update to `Sentry.reactRouterV7BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, wrap `<Routes />` using `Sentry.withSentryReactRouterV7Routing`. This creates a higher order component, which will enable Sentry to reach your router context. You can also use `Sentry.withSentryReactRouterV7Routing` for Routes inside `BrowserRouter`, `MemoryRouter`, and `HashRouter` components.
58+
If you're using the `<Routes />` component to define your routes, update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV7BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, wrap `<Routes />` using `Sentry.withSentryReactRouterV7Routing`. This creates a higher order component, which will enable Sentry to reach your router context. You can also use `Sentry.withSentryReactRouterV7Routing` for routes inside `BrowserRouter`, `MemoryRouter`, and `HashRouter` components.
5859

5960
```javascript {3-11, 18-24, 29, 33-35}
6061
import React from "react";
@@ -96,11 +97,11 @@ ReactDOM.render(
9697
);
9798
```
9899

99-
This wrapping is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
100+
This wrapper is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
100101

101-
### Usage With `useRoutes` Hook
102+
## Usage With `useRoutes` Hook
102103

103-
If you specify your route definitions as an object to the [`useRoutes` hook](https://reactrouter.com/en/main/hooks/use-routes), update to `Sentry.reactRouterV7BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, use `Sentry.wrapUseRoutesV7` to create a patched `useRoutes` hook that instruments your routes with Sentry.
104+
If you specify your route definitions as an object to the [`useRoutes` hook](https://reactrouter.com/en/main/hooks/use-routes), update your `Sentry.browserTracingIntegration` to `Sentry.reactRouterV7BrowserTracingIntegration` inside `Sentry.init` and provide the required React hooks and router functions. Then, use `Sentry.wrapUseRoutesV7` to create a patched `useRoutes` hook that instruments your routes with Sentry.
104105

105106
<Alert level="warning" title="Important">
106107
Call `wrapUseRoutesV7` outside of a React component, as in the example below. We also recommend that you assign the wrapped hook to a variable starting with `use`, as per [React's documentation](https://react.dev/learn/reusing-logic-with-custom-hooks#hook-names-always-start-with-use).
@@ -151,7 +152,7 @@ ReactDOM.render(
151152

152153
Now, Sentry should generate `pageload`/`navigation` transactions with parameterized transaction names (for example, `/teams/:teamid/user/:userid`), where applicable. This is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.
153154

154-
### Custom Error Boundaries
155+
## Custom Error Boundaries
155156

156157
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.
157158

@@ -202,7 +203,7 @@ export function YourCustomRootErrorBoundary() {
202203

203204
```
204205

205-
## Next Steps:
206+
## Next Steps
206207

207208
- [Return to **Getting Started**](../../)
208209
- [Return to the main integrations page](../)

0 commit comments

Comments
 (0)