-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
49 lines (43 loc) · 1.03 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
import React, { Component } from "react";
import { connect } from "react-redux";
import { counterIncrement, counterDecrement } from "./actions";
import Button from "../Button";
export class Counter extends Component {
constructor(props) {
super(props);
this.increment = this.increment.bind(this);
this.decrement = this.decrement.bind(this);
}
increment() {
this.props.dispatch(counterIncrement());
};
decrement() {
this.props.dispatch(counterDecrement());
};
render() {
return (
<div className="counter-card">
<h2 className="count">{this.props.count}</h2>
<Button
className="increment"
onClick={this.increment}
>
Increment
</Button>
<Button
className="decrement"
onClick={this.decrement}
>
Decrement
</Button>
</div>
);
}
}
const mapStateToProps = (state) => ({
count: state.count,
})
export default connect(mapStateToProps, {
counterIncrement,
counterDecrement
})(Counter)