-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
64 lines (56 loc) · 1.18 KB
/
App.js
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
63
64
import React, { Component } from 'react';
import {
BrowserRouter as Router,
Link,
Redirect,
Route,
Switch,
} from 'react-router-dom'
function Users () {
return (
<div>
<h1>Users</h1>
<ul>
<li>
<Link to='/users/sparragus'>
See @sparragus profile
</Link>
</li>
<li>
<Link to='/profile/horse_js'>
See @horse_js profile (should redirect from /profile/horse_js to /users/horse_js)
</Link>
</li>
</ul>
</div>
)
}
function Profile ({ match }) {
return (
<div>
<h1>
Profile of {match.params.username}
</h1>
<p>
Go back to the list of <Link to='/users'>users</Link>.
</p>
</div>
)
}
class App extends Component {
render() {
return (
<div className="App">
<Router>
<Switch>
<Redirect from='/profile/:username' to='/users/:username' />
<Route path='/users/:username' component={Profile} />
<Route path='/users' component={Users} />
<Redirect from='/' to='/users' />
</Switch>
</Router>
</div>
);
}
}
export default App;