Skip to content

Instantly share code, notes, and snippets.

@nesbtesh
Last active August 26, 2016 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesbtesh/ac1890d642ba866410308c19c52bdb49 to your computer and use it in GitHub Desktop.
Save nesbtesh/ac1890d642ba866410308c19c52bdb49 to your computer and use it in GitHub Desktop.
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