Created
September 12, 2017 16:41
-
-
Save anacampesan/6c60992bb7fb6b74c3d8ce9b1053a973 to your computer and use it in GitHub Desktop.
Bind functions to events in React
This file contains 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'; | |
export default class Print extends React.Component { | |
constructor() { | |
super() | |
this.printStuff = this.printStuff.bind(this); | |
} | |
printStuff() { | |
console.log('It works! :)'); | |
} | |
render() { | |
return( | |
<button onClick={this.printStuff}>click</button> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment