-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounterButton.js
More file actions
38 lines (29 loc) · 793 Bytes
/
CounterButton.js
File metadata and controls
38 lines (29 loc) · 793 Bytes
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
import React, {Component, PureComponent} from "react";
class CounterButton extends PureComponent{
constructor() {
super();
this.state={
count :0
}
}
// shouldComponentUpdate(nextProps, nextState) {
// if(this.state.count!==nextState.count){
// return true
// }
// return false
//
// }
updateCount =()=>{
this.setState(state=>{
return {count:this.state.count+1}})
}
render() {
console.log("CounterButton")
return(
<div>
<button color={this.props.color} onClick={this.updateCount}>Count :{this.state.count} </button>
</div>
)
}
}
export default CounterButton