Skip to content

Commit 688138f

Browse files
committed
17-routes
1 parent 70f5979 commit 688138f

File tree

4 files changed

+77
-12
lines changed

4 files changed

+77
-12
lines changed

app/index.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@ import * as ReactDOM from "react-dom/client";
33
import "./index.css";
44
import Popular from "./components/Popular";
55
import Battle from "./components/Battle";
6+
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
67

78
class App extends React.Component {
89
render() {
910
return (
10-
<div className="light">
11-
<div className="container">
12-
<Popular />
11+
<Router>
12+
<div className="light">
13+
<div className="container">
14+
<Routes>
15+
<Route path="/" element={<Popular />} />
16+
<Route path="/battle" element={<Battle />} />
17+
</Routes>
18+
</div>
1319
</div>
14-
</div>
20+
</Router>
1521
);
1622
}
1723
}

package-lock.json

Lines changed: 61 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dependencies": {
1919
"prop-types": "^15.8.1",
2020
"react": "^18.2.0",
21-
"react-dom": "^18.2.0"
21+
"react-dom": "^18.2.0",
22+
"react-router-dom": "^6.3.0"
2223
},
2324
"devDependencies": {
2425
"@babel/core": "^7.18.10",

webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
output: {
77
path: path.resolve(__dirname, "dist"),
88
filename: "index_bundle.js",
9+
publicPath: "/",
910
},
1011
module: {
1112
rules: [
@@ -22,4 +23,7 @@ module.exports = {
2223
template: "app/index.html",
2324
}),
2425
],
26+
devServer: {
27+
historyApiFallback: true,
28+
},
2529
};

0 commit comments

Comments
 (0)