Last active
August 26, 2016 01:50
-
-
Save nesbtesh/ac1890d642ba866410308c19c52bdb49 to your computer and use it in GitHub Desktop.
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
export default class BindFunctionExample extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
hidden: true, | |
}; | |
this.toggleHidden = this.toggleHidden.bind(this); | |
} | |
toggleHidden() { | |
const hidden = !this.state.hidden; | |
this.setState({hidden}) | |
} | |
render(){ | |
return( | |
<button onClick={this.toggleHidden} /> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment