Created
November 5, 2019 18:17
-
-
Save sabesansathananthan/fb8af66210c58e3fa35d1f84d2d2087e to your computer and use it in GitHub Desktop.
example 1 for react best practice to handle this
This file contains hidden or 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
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