Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created November 5, 2019 18:34
Show Gist options
  • Save sabesansathananthan/155a33fa52dadaf9e6909fc80ff5bcab to your computer and use it in GitHub Desktop.
Save sabesansathananthan/155a33fa52dadaf9e6909fc80ff5bcab to your computer and use it in GitHub Desktop.
example 4 for react best practice to handle this
class Message extends Components {
constructor(props) {
super(props);
this.state = { message: "Hello" };
}
logMessage = () => {
const { message } = this.state;
console.log(message);
}
render() {
return (
<input type="button" value="Log" onClick={this.logMessage} />
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment