Last active
November 6, 2018 02:10
-
-
Save chentsulin/dcc48520aef326628b46ebb85a4bd3df to your computer and use it in GitHub Desktop.
counter class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter { | |
state = { | |
value: this.props.defaultValue | |
}; | |
handlePlusOne = () => { | |
this.setState(() => ({ value: this.state.value + 1 })); | |
}; | |
render() { | |
return ( | |
<> | |
<div>{this.state.value}</div> | |
<button onClick={this.handlePlusOne}>+</button> | |
</> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment