Skip to content

Instantly share code, notes, and snippets.

@joshthecoder
Created June 10, 2015 04:43
Show Gist options
  • Save joshthecoder/988dc840d94b5eee6f09 to your computer and use it in GitHub Desktop.
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)
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