-
-
Notifications
You must be signed in to change notification settings - Fork 303
/
Copy pathindex.js
71 lines (63 loc) · 1.6 KB
/
index.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
69
70
71
import {
decrement,
decrementAsync,
increment,
incrementAsync,
} from '../../modules/counter'
import React from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { push } from 'connected-react-router'
const Home = (props) => (
<div>
<h1>Home</h1>
<p>Count: {props.count}</p>
{(props.isIncrementing || props.isDecrementing) && <div>Loading ....</div>}
<p>
<button
onClick={props.increment}
disabled={props.isDecrementing || props.isIncrementing}>
Increment
</button>
<button
onClick={props.incrementAsync}
disabled={props.isDecrementing || props.isIncrementing}>
Increment Async
</button>
</p>
<p>
<button
onClick={props.decrement}
disabled={props.isDecrementing || props.isIncrementing}>
Decrement
</button>
<button
onClick={props.decrementAsync}
disabled={props.isDecrementing || props.isIncrementing}>
Decrement Async
</button>
</p>
<p>
<button onClick={() => props.changePage()}>
Go to about page via redux
</button>
</p>
</div>
)
const mapStateToProps = ({ counter }) => ({
count: counter.count,
isIncrementing: counter.isIncrementing,
isDecrementing: counter.isDecrementing,
})
const mapDispatchToProps = (dispatch) =>
bindActionCreators(
{
increment,
incrementAsync,
decrement,
decrementAsync,
changePage: () => push('/about-us'),
},
dispatch
)
export default connect(mapStateToProps, mapDispatchToProps)(Home)