Created
June 10, 2015 04:43
-
-
Save joshthecoder/988dc840d94b5eee6f09 to your computer and use it in GitHub Desktop.
React Component w/ Function bind operator (https://github.com/zenparsing/es-function-bind)
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 Button extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {clickCount: 0}; | |
} | |
_onClick(e) { | |
e.preventDefault(); | |
this.setState({clickCount: this.state.clickCount + 1}); | |
} | |
render() { | |
return ( | |
<button onClick={::this._onClick}> | |
You have clicked me {this.state.clickCount} times | |
</button> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment