Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created November 5, 2019 18:17
Show Gist options
  • Save sabesansathananthan/fb8af66210c58e3fa35d1f84d2d2087e to your computer and use it in GitHub Desktop.
Save sabesansathananthan/fb8af66210c58e3fa35d1f84d2d2087e to your computer and use it in GitHub Desktop.
example 1 for react best practice to handle this
class Bar 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