Skip to content

Commit e012ef9

Browse files
committed
chore: Updated remaining docs and tests for react-router-dom v6
1 parent ae469ef commit e012ef9

File tree

12 files changed

+71
-185
lines changed

12 files changed

+71
-185
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
"@types/reach__router": "^1.3.9",
6767
"@types/react": "^17.0.36",
6868
"@types/react-dom": "^17.0.11",
69-
"@types/react-router": "^5.1.17",
70-
"@types/react-router-dom": "^5.3.1",
7169
"@types/react-test-renderer": "^17.0.1",
7270
"@types/react-transition-group": "^4.4.3",
7371
"chokidar": "^3.5.2",

packages/dev-utils/src/sandbox/createPackageJson.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ function toDependencyJson(
1717
);
1818
}
1919

20-
const SIMPLE_AT_TYPES = [
21-
"qs",
22-
"react-router",
23-
"react-router-dom",
24-
"react-transition-group",
25-
"react-virtualized",
26-
];
20+
const SIMPLE_AT_TYPES = ["qs", "react-transition-group", "react-virtualized"];
2721

2822
function getTypesPackage(packageName: string): string | null {
2923
if (SIMPLE_AT_TYPES.includes(packageName)) {

packages/documentation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"react-hook-form": "^7.20.2",
3838
"react-marked-renderer": "^1.0.0",
3939
"react-md": "^3.1.1",
40-
"react-router-dom": "^5.3.0",
40+
"react-router-dom": "^6.0.2",
4141
"react-swipeable": "^6.2.0",
4242
"react-transition-group": "^4.4.2",
4343
"react-virtualized": "^9.22.3",

packages/documentation/src/components/Demos/Link/ThirdPartyRoutingLibraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ props into the react-md `Link`:
1616
```tsx
1717
import { ReactElement } from "react";
1818
import { render } from "react-dom";
19-
import { Link as ReactRouterLink, LinkProps } from "react-router";
19+
import { Link as ReactRouterLink, LinkProps } from "react-router-dom";
2020
import { Link as ReactMDLink } from "@react-md/link";
2121

2222
function Link(props: LinkProps): ReactElement {

packages/layout/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ import { Text } from "@react-md/typography";
8888
import {
8989
BrowserRouter,
9090
Link,
91+
Routes,
9192
Route,
92-
Switch,
9393
useLocation,
9494
} from "react-router-dom";
9595

@@ -149,12 +149,12 @@ function App(): ReactElement {
149149
navHeaderTitle="Example Nav Title"
150150
treeProps={useLayoutNavigation(navItems, pathname, Link)}
151151
>
152-
<Switch>
153-
<Route path="/route-1" component={Route1} />
154-
<Route path="/route-2" component={Route2} />
155-
<Route path="/route-3" component={Route3} />
156-
<Route path="/" component={Home} />
157-
</Switch>
152+
<Routes>
153+
<Route path="/" element={<Home />} />
154+
<Route path="route-1" element={<Route1 />} />
155+
<Route path="route-2" element={<Route2 />} />
156+
<Route path="route-3" element={<Route3 />} />
157+
</Routes>
158158
</Layout>
159159
);
160160
}

packages/layout/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"devDependencies": {
5454
"react": "^17.0.2",
5555
"react-dom": "^17.0.1",
56-
"react-router-dom": "^5.3.0"
56+
"react-router-dom": "^6.0.2"
5757
},
5858
"peerDependencies": {
5959
"react": ">= 16.14",

packages/layout/src/__tests__/Layout.tsx

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Link,
55
BrowserRouter,
66
useLocation,
7-
Switch,
7+
Routes,
88
Route,
99
} from "react-router-dom";
1010
import { mocked } from "ts-jest/utils";
@@ -498,6 +498,18 @@ describe("Layout", () => {
498498

499499
describe("navigation behavior", () => {
500500
it("should work with react-router", () => {
501+
function Route2(): ReactElement {
502+
return (
503+
<>
504+
<h1>Route 2</h1>
505+
<Routes>
506+
<Route path="1" element={<h2>Route 2-1</h2>} />
507+
<Route path="2" element={<h2>Route 2-2</h2>} />
508+
<Route path="3" element={<h2>Route 2-3</h2>} />
509+
</Routes>
510+
</>
511+
);
512+
}
501513
function Test(): ReactElement {
502514
const { pathname } = useLocation();
503515
return (
@@ -508,34 +520,13 @@ describe("Layout", () => {
508520
Link
509521
)}
510522
>
511-
<Switch>
512-
<Route path="/" exact>
513-
<h1>Home</h1>
514-
</Route>
515-
<Route path="/route-1">
516-
<h1>Route 1</h1>
517-
</Route>
518-
<Route path="/route-2">
519-
<h1>Route 2</h1>
520-
<Switch>
521-
<Route path="/route-2/1">
522-
<h2>Route 2-1</h2>
523-
</Route>
524-
<Route path="/route-2/2">
525-
<h2>Route 2-2</h2>
526-
</Route>
527-
<Route path="/route-2/3">
528-
<h2>Route 2-3</h2>
529-
</Route>
530-
</Switch>
531-
</Route>
532-
<Route path="/route-3">
533-
<h1>Route 3</h1>
534-
</Route>
535-
<Route path="/route-4">
536-
<h1>Route 4</h1>
537-
</Route>
538-
</Switch>
523+
<Routes>
524+
<Route path="/" element={<h1>Home</h1>} />
525+
<Route path="route-1" element={<h1>Route 1</h1>} />
526+
<Route path="route-2/*" element={<Route2 />} />
527+
<Route path="route-3" element={<h1>Route 3</h1>} />
528+
<Route path="route-4" element={<h1>Route 4</h1>} />
529+
</Routes>
539530
</Layout>
540531
);
541532
}

packages/link/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import {
4343
Link as ReactRouterLink,
4444
LinkProps as ReactRouterLinkProps,
4545
BrowserRouter,
46+
Routes,
47+
Route,
4648
} from "react-router-dom";
4749
import { Link as ReactMDLink, LinkProps as RMDLinkProps } from "@react-md/link";
4850

@@ -66,8 +68,10 @@ function App(): ReactElement {
6668
<Link to="/">Home</Link>
6769
<Link to="/about">About</Link>
6870

69-
<Route exact path="/" component={Home} />
70-
<Route path="/about" component={About} />
71+
<Routes>
72+
<Route path="/" element={<Home />} />
73+
<Route path="about" element={<About />} />
74+
</Routes>
7175
</BrowserRouter>
7276
);
7377
}

packages/link/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@reach/router": "^1.3.4",
4141
"react": "^17.0.2",
4242
"react-dom": "^17.0.1",
43-
"react-router-dom": "^5.3.0"
43+
"react-router-dom": "^6.0.2"
4444
},
4545
"peerDependencies": {
4646
"react": ">= 16.14",

packages/link/src/__tests__/Link.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Link as ReachLink } from "@reach/router";
22
import { render } from "@testing-library/react";
3-
import { Link as ReactRouterLink, StaticRouter } from "react-router-dom";
3+
import { Link as ReactRouterLink } from "react-router-dom";
4+
import { StaticRouter } from "react-router-dom/server";
45
import renderer from "react-test-renderer";
56

67
import { Link } from "../Link";
@@ -27,7 +28,7 @@ describe("Link", () => {
2728
[key: string]: any;
2829
}) =>
2930
renderer.create(
30-
<StaticRouter context={{}}>
31+
<StaticRouter location="/">
3132
<Link {...props} component={ReactRouterLink}>
3233
{children}
3334
</Link>

0 commit comments

Comments
 (0)