Created
January 25, 2016 14:08
-
-
Save a-double/cd8c6b4b36533c20128e to your computer and use it in GitHub Desktop.
Handling "this" in React with ES6
This file contains hidden or 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
| 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