-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp5.jsx
More file actions
41 lines (37 loc) · 1.11 KB
/
Copy pathp5.jsx
File metadata and controls
41 lines (37 loc) · 1.11 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
import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter, Route, Switch, Redirect, Link } from 'react-router-dom';
import Example from './components/example/Example';
import States from './components/states/States';
import Header from './components/header/Header';
function Navigation() {
return (
<nav style={{ backgroundColor: '#333', padding: '10px', color: '#fff' }}>
<Link to="/example" style={{ color: '#fff', textDecoration: 'none', marginRight: '10px' }}>Example</Link> |
<Link to="/states" style={{ color: '#fff', textDecoration: 'none' }}>States</Link>
</nav>
);
}
function RouterComponent() {
return (
<Switch>
<Route path="/states" component={States} />
<Route path="/example" component={Example} />
<Route exact path="/" render={() => <Redirect to="/example" />} />
</Switch>
);
}
function P5() {
return (
<div>
<Header />
<HashRouter>
<div>
<Navigation />
<RouterComponent />
</div>
</HashRouter>
</div>
);
}
ReactDOM.render(<P5 />, document.getElementById('reactapp'));