Skip to content

Commit 3c4d1ea

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

10 files changed

Lines changed: 23 additions & 30 deletions

File tree

examples/create-react-app/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ 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-
- [jsconfig.json](./jsconfig.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
12-
- a reusable [Layout.jsx](./src/components/Layout/Layout.jsx) that:
10+
- a reusable [Layout.js](./src/components/Layout/Layout.js) that:
1311
- updates all the icons to use `SVGIcon`s instead of `FontIcon`s
1412
- initializes the `Layout` component from `react-md` with navigation items
1513
- uses [react-router-dom](https://www.npmjs.com/package/react-router-dom) as the routing library

examples/create-react-app/jsconfig.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/create-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react": "^17.0.1",
1616
"react-dom": "^17.0.1",
1717
"react-md": "latest",
18-
"react-router-dom": "^5.2.0",
18+
"react-router-dom": "^6.0.2",
1919
"react-scripts": "4.0.3",
2020
"sass": "^1.37.5",
2121
"web-vitals": "^2.1.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Routes, Route } from 'react-router-dom';
2+
3+
import Layout from './components/Layout';
4+
import Home from './components/Home';
5+
import Route1 from './components/Route1';
6+
7+
export default function App() {
8+
return (
9+
<Layout>
10+
<Routes>
11+
<Route path="/" element={<Home />} />
12+
<Route path="route-1" element={<Route1 />} />
13+
</Routes>
14+
</Layout>
15+
);
16+
}

examples/create-react-app/src/App.jsx

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.

examples/create-react-app/src/components/Layout/Layout.jsx renamed to examples/create-react-app/src/components/Layout/Layout.js

File renamed without changes.

examples/create-react-app/src/components/Layout/navItems.jsx renamed to examples/create-react-app/src/components/Layout/navItems.js

File renamed without changes.
File renamed without changes.
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

0 commit comments

Comments
 (0)