Skip to content

Instantly share code, notes, and snippets.

@john1jan
Created March 20, 2017 15:07
Show Gist options
  • Save john1jan/c47148ff5d8c83cdc304794aef1c4257 to your computer and use it in GitHub Desktop.
Save john1jan/c47148ff5d8c83cdc304794aef1c4257 to your computer and use it in GitHub Desktop.
ConstructorBindingSample
class App extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'Hello World' };
this.print = this.print.bind(this);
}
render() {
return <div>
<p> Binding Revealed</p>
<input type="button" value="Print" onClick={this.print} />
<Sample />
</div>
}
print() {
console.log("print method called!");
console.log(this.state.message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment