forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
42 lines (38 loc) · 1018 Bytes
/
app.js
File metadata and controls
42 lines (38 loc) · 1018 Bytes
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
import React from 'react';
import createHistory from 'history/lib/createHashHistory';
import { Router, Route, Link } from 'react-router';
var User = React.createClass({
render() {
var { query } = this.props.location;
var age = query && query.showAge ? '33' : '';
var { userID } = this.props.params;
return (
<div className="User">
<h1>User id: {userID}</h1>
{age}
</div>
);
}
});
var App = React.createClass({
render() {
return (
<div>
<ul>
<li><Link to="/user/bob">Bob</Link></li>
<li><Link to="/user/bob" query={{showAge: true}}>Bob With Query Params</Link></li>
<li><Link to="/user/sally">Sally</Link></li>
</ul>
{this.props.children}
</div>
);
}
});
var history = createHistory();
React.render((
<Router history={history}>
<Route path="/" component={App}>
<Route path="user/:userID" component={User} />
</Route>
</Router>
), document.getElementById('example'));