Skip to content

Commit ae469ef

Browse files
committed
chore(examples): Updated create-react-app-typescript example to use react-router-dom v6
1 parent 3c4d1ea commit ae469ef

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

examples/create-react-app-typescript/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
66

77
This example will setup an example Create React App + ReactMD app that has the following features:
88

9-
- [tsconfig.json](./tsconfig.json) to allow absolute imports instead of relative imports from the `"src"` directory
10-
- `import MyComponent from "components/MyComponent"` instead of `import MyComponent from "../../components/MyComponent"`
119
- [\_everything.scss](./src/_everything.scss) to override the default `react-md` theme and feature toggles
1210
- a reusable [Layout.tsx](./src/components/Layout/Layout.tsx) that:
1311
- updates all the icons to use `SVGIcon`s instead of `FontIcon`s

examples/create-react-app-typescript/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
"@types/node": "^16.6.1",
1717
"@types/react": "^17.0.17",
1818
"@types/react-dom": "^17.0.9",
19-
"@types/react-router-dom": "^5.1.5",
2019
"react": "^17.0.1",
2120
"react-dom": "^17.0.1",
2221
"react-md": "latest",
23-
"react-router-dom": "^5.2.0",
22+
"react-router-dom": "^6.0.2",
2423
"react-scripts": "4.0.3",
2524
"sass": "^1.36.0",
2625
"typescript": "^4.0.3",
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import type { ReactElement } from "react";
2-
import { Route, Switch } from "react-router-dom";
2+
import { Routes, Route } from "react-router-dom";
33

4-
import Layout from "components/Layout";
5-
import Home from "components/Home";
6-
import Route1 from "components/Route1";
4+
import Layout from "./components/Layout";
5+
import Home from "./components/Home";
6+
import Route1 from "./components/Route1";
77

88
export default function App(): ReactElement {
99
return (
1010
<Layout>
11-
<Switch>
12-
<Route path="/" exact component={Home} />
13-
<Route path="/route-1" component={Route1} />
14-
</Switch>
11+
<Routes>
12+
<Route path="/" element={<Home />} />
13+
<Route path="route-1" element={<Route1 />} />
14+
</Routes>
1515
</Layout>
1616
);
1717
}

examples/create-react-app-typescript/src/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import ReactDOM from "react-dom";
21
import "./index.scss";
2+
import ReactDOM from "react-dom";
3+
import { BrowserRouter } from "react-router-dom";
4+
35
import App from "./App";
4-
import { BrowserRouter as Router } from "react-router-dom";
56
import reportWebVitals from "./reportWebVitals";
67

78
ReactDOM.render(
8-
<Router>
9+
<BrowserRouter>
910
<App />
10-
</Router>,
11+
</BrowserRouter>,
1112
document.getElementById("root")
1213
);
1314

examples/create-react-app-typescript/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"compilerOptions": {
33
"target": "es5",
44
"lib": ["dom", "dom.iterable", "esnext"],
5-
"baseUrl": "src",
6-
"rootDir": "src",
75
"allowJs": true,
86
"skipLibCheck": true,
97
"esModuleInterop": true,

0 commit comments

Comments
 (0)