-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel.js
45 lines (38 loc) · 829 Bytes
/
panel.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
import React from 'react';
import Button from './button';
export default class Panel extends React.Component {
constructor(props) {
super(props);
this.state = {
number: 0,
};
this.up = this.up.bind(this);
this.down = this.down.bind(this);
this.zero = this.zero.bind(this);
}
up() {
this.setState({
number: ++this.state.number,
});
}
down() {
this.setState({
number: --this.state.number,
});
}
zero() {
this.setState({
number: 0,
});
}
render() {
return (
<div>
<span>{ this.state.number }</span>
<Button onClick={this.up} type="primary">Up</Button>
<Button onClick={this.down} type="primary">Down</Button>
<Button onClick={this.zero} type="primary">Zero</Button>
</div>
);
}
};