Skip to content

Instantly share code, notes, and snippets.

@adaschevici
Created July 9, 2017 14:01
Show Gist options
  • Save adaschevici/b29890dcb085739220db09dc2a324a80 to your computer and use it in GitHub Desktop.
Save adaschevici/b29890dcb085739220db09dc2a324a80 to your computer and use it in GitHub Desktop.
class ExampleComponent extends React.Component {
constructor() {
super();
this. _handleClick = this. _handleClick.bind(this);
}
render() {
return <div onClick={this._handleClick}>Hello, world.</div>;
}
_handleClick() {
console.log(this); // this is an ExampleComponent
}
const boundHandleClick = () => {
console.log(this); // this is an ExampleComponent
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment