Skip to content

Instantly share code, notes, and snippets.

@ameliabradley
Created January 14, 2018 00:14
Show Gist options
  • Save ameliabradley/44790bfba7eb2a96c4b47aa7762e0c41 to your computer and use it in GitHub Desktop.
Save ameliabradley/44790bfba7eb2a96c4b47aa7762e0c41 to your computer and use it in GitHub Desktop.
class LoggingButton extends React.Component {
// This syntax ensures `this` is bound within handleClick.
// Warning: this is *experimental* syntax.
handleClick = () => {
console.log('this is:', this);
}
render() {
return (
<button onClick={this.handleClick}>
Click me
</button>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment