-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathReact-Router-Dom
More file actions
62 lines (53 loc) · 1.61 KB
/
React-Router-Dom
File metadata and controls
62 lines (53 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
React router dom:
import React from "react";
import { BrowserRouter as Router, Route, Link, Routes } from "react-router-dom";
import About from "./components/About";
import Home from "./components/Home";
import Topics from "./components/Topics";
export default function App() {
return (
<Router>
<div>
<Link to="/">Home</Link> <br />
<Link to="/about">About</Link> <br />
<Link to="/topics">Topics</Link> <br />
<hr />
<Routes>
<Route exact path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="/topics" element={<Topics />} />
</Routes>
</div>
</Router>
);
}
-------------------------
import React from "react";
const Topics = () => (
<div>
<h2>Topics</h2>
</div>
);
export default Topics;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
ANOTHER WAY
import React from "react";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import About from "./components/About";
import Home from "./components/Home";
import Topics from "./components/Topics";
export default function App() {
return (
<Router>
<div>
<Link to="/">Home</Link> <br />
<Link to="/about">About</Link> <br />
<Link to="/topics">Topics</Link> <br />
<hr />
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
<Route path="/topics" component={Topics} />
</div>
</Router>
);
}