You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/shared/_migrate-to-react-router-v6.mdx
+32-4Lines changed: 32 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Follow the steps below to start using `react-router` v6 in your plugin:
16
16
17
17
Enable using `react-router@v6` by setting the following feature flag in `<project-root>/.cprc.json`:
18
18
19
-
```json
19
+
```json title="<project-root>/.cprc.json"
20
20
{
21
21
"features": {
22
22
"useReactRouterV6": true
@@ -32,7 +32,7 @@ After updating the build configuration, it is likely that you will need to make
32
32
33
33
#### 2. Use `<Routes>` instead of `<Switch>`
34
34
35
-
```typescript
35
+
```typescript title="src/Routes.tsx"
36
36
// Using <Routes> instead of <Switch> in `react-router` v6
37
37
import { Routes } from'react-router-dom';
38
38
@@ -47,7 +47,7 @@ return (
47
47
48
48
#### 3. Remove the `exact` prop from `<Route>` components
49
49
50
-
```typescript
50
+
```typescript title="src/Routes.tsx"
51
51
return (
52
52
<Routes>
53
53
{/* BAD (Until v5) */}
@@ -60,6 +60,34 @@ return (
60
60
);
61
61
```
62
62
63
-
#### 4. Follow the original `react-router` migration guide for more in-depth changes
63
+
#### 4. Fix test failures with location service methods
64
+
65
+
When using `locationService.replace()`, `locationService.push()`, or similar methods from `@grafana/runtime`, your tests might fail after migrating to React Router v6. Solve this by using the `<LocationServiceProvider />` component (introduced in Grafana 11.2.0) to create a provider for the location service in your tests.
0 commit comments