Created
November 5, 2019 18:34
-
-
Save sabesansathananthan/155a33fa52dadaf9e6909fc80ff5bcab to your computer and use it in GitHub Desktop.
example 4 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 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