Skip to content

Instantly share code, notes, and snippets.

@Rplus
Last active May 4, 2018 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rplus/8b0bfe0a9744ae8b9aa0291a19a2e4f6 to your computer and use it in GitHub Desktop.
Save Rplus/8b0bfe0a9744ae8b9aa0291a19a2e4f6 to your computer and use it in GitHub Desktop.
<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