Skip to content

Instantly share code, notes, and snippets.

@a-double
Created January 25, 2016 14:08
Show Gist options
  • Select an option

  • Save a-double/cd8c6b4b36533c20128e to your computer and use it in GitHub Desktop.

Select an option

Save a-double/cd8c6b4b36533c20128e to your computer and use it in GitHub Desktop.
Handling "this" in React with ES6
import React from 'react';
class Thing extends React.Component {
constructor( props ) {
super( props );
this.handleClick = this.handleClick.bind( this );
}
handleClick() {
console.log( this );
}
render() {
return (
<div onClick={this.handleClick}></div>
);
}
}
export default Thing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment