Skip to content

Instantly share code, notes, and snippets.

@fzzzy
Last active November 2, 2016 17:02
Show Gist options
  • Save fzzzy/3b2b42914d1d18c2f5fb6c5cb0d9f21f to your computer and use it in GitHub Desktop.
Save fzzzy/3b2b42914d1d18c2f5fb6c5cb0d9f21f to your computer and use it in GitHub Desktop.
<DOCTYPE html>
<html>
<head>
<title>Hello, React</title>
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<div id="root">
</div>
<script type="text/babel">
class HelloWorld extends React.Component {
constructor(props) {
super(props);
this.state = {
clicks: 0
};
}
onClick() {
this.setState({clicks: this.state.clicks + 1});
}
render() {
return <div>
<h1>Hello, World!</h1>
<p>Foo was: { this.props.foo }</p>
<button onClick={ this.onClick.bind(this) }>
Click Me!
</button>
<p>Button has been clicked { this.state.clicks } times.</p>
</div>;
}
}
ReactDOM.render(
<HelloWorld foo="foo" />,
document.getElementById("root")
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment