-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
43 lines (36 loc) · 836 Bytes
/
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
import React, { Component } from "react";
import Button from "../Button";
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
count: 0
}
this.increment = this.increment.bind(this);
this.decrement = this.decrement.bind(this);
}
increment() {
this.setState(prevState => ({ count: prevState.count + 1 }));
};
decrement() {
this.setState(prevState => ({ count: prevState.count - 1 }));
};
render() {
return (
<div className="counter-card">
<h2 className="count">{this.state.count}</h2>
<Button
onClick={this.increment}
>
Increment
</Button>
<Button
onClick={this.decrement}
>
Decrement
</Button>
</div>
);
}
}
export default Counter;