-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
68 lines (62 loc) · 1.85 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
65
66
67
68
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Match, Link, StaticRouter } from 'react-router'
import { push, replace } from './react-router-redux/'
function mapStateToProps(state) {
return {
location: state.routing.location,
action: state.routing.action,
}
}
const mapDispatchToProps = {
onPush: push,
onReplace: replace,
}
@connect(mapStateToProps, mapDispatchToProps)
class App extends Component {
static propTypes = {
location: PropTypes.object.isRequired,
action: PropTypes.string.isRequired,
onPush: PropTypes.func.isRequired,
onReplace: PropTypes.func.isRequired,
}
render() {
return (
<StaticRouter
location={this.props.location}
action={this.props.action}
onPush={this.props.onPush}
onReplace={this.props.onReplace}
basename="/react-router4-redux-example"
>
<div style={{ padding: 15, fontFamily: 'Helvetica, sans-serif' }}>
<div><Link to="/">Home</Link></div>
<div><Link to="/foo">Foo</Link></div>
<div><Link to="/bar">Bar</Link></div>
<div>
<Match pattern="/" exactly component={() => {
document.title = 'Home'
return <h1>Home!</h1>
}} />
<Match pattern="/foo" exactly render={() => {
document.title = 'Foo'
return <h1>Foo!</h1>
}} />
<Match pattern="/bar" exactly render={() => {
document.title = 'Bar'
return <h1>Bar!</h1>
}} />
</div>
<a
href="https://github.com/lourd/react-router4-redux-example"
target="_blank"
style={{ display: 'block' }}
>
Source code on GitHub
</a>
</div>
</StaticRouter>
)
}
}
export default App