-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathNavigation.tsx
45 lines (42 loc) · 1.09 KB
/
Navigation.tsx
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
import {
BrowserRouter as Router,
Switch,
Route,
NavLink
} from 'react-router-dom';
import logo from '../logo.svg';
export const Navigation = () => {
return (
<Router>
<div className="main-layout">
<nav>
<img src={ logo } alt="React Logo" />
<ul>
<li>
<NavLink to="/" activeClassName="nav-active" exact>Home</NavLink>
</li>
<li>
<NavLink to="/about" activeClassName="nav-active" exact>About</NavLink>
</li>
<li>
<NavLink to="/users" activeClassName="nav-active" exact>Users</NavLink>
</li>
</ul>
</nav>
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>
<Route path="/about">
<h1>About</h1>
</Route>
<Route path="/users">
<h1>Users</h1>
</Route>
<Route path="/">
<h1>Home</h1>
</Route>
</Switch>
</div>
</Router>
);
}