Last active
May 4, 2018 09:24
-
-
Save Rplus/8b0bfe0a9744ae8b9aa0291a19a2e4f6 to your computer and use it in GitHub Desktop.
This file contains 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
<script src="https://unpkg.com/react@15/dist/react.min.js"> </script><script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"> | |
</script> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<div id="root"></div> | |
<script type="text/babel"> | |
class Hello extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
message: "my friend (from state)!" | |
}; | |
} | |
updateMessage = () => { | |
this.setState({ | |
message: "my friend (from changed state)!" | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Hello {this.state.message}!</h1> | |
<button onClick={this.updateMessage}>Click me!</button> | |
</div> | |
) | |
} | |
} | |
ReactDOM.render( | |
<Hello message="my friend" />, | |
document.getElementById("root") | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment