Created
September 14, 2020 11:01
-
-
Save michaelkutuzov/8f83aefc3c1fe5e6adef10b3b995acce to your computer and use it in GitHub Desktop.
Fiber inside 1
This file contains hidden or 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 ClickCounter extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = {count: 0}; | |
| this.handleClick = this.handleClick.bind(this); | |
| } | |
| handleClick() { | |
| this.setState((state) => { | |
| return {count: state.count + 1}; | |
| }); | |
| } | |
| render() { | |
| return [ | |
| <button key="1" onClick={this.handleClick}>Update counter</button>, | |
| <span key="2">{this.state.count}</span> | |
| ] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment