Created
October 2, 2017 15:10
-
-
Save bcuz/1caa2a9e47a56676795c62571a302805 to your computer and use it in GitHub Desktop.
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 MyComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
itemCount: 0 | |
}; | |
this.addItem = this.addItem.bind(this); | |
} | |
addItem() { | |
this.setState({ | |
itemCount: this.state.itemCount + 1 | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<button onClick = {this.addItem}>Click Me</button> | |
<h1>Current Item Count: {this.state.itemCount}</h1> | |
</div> | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment