Skip to content

Instantly share code, notes, and snippets.

@allenhwkim
Last active September 11, 2017 00:46
Show Gist options
  • Save allenhwkim/2436baaaedd01c5aba203c92fa8ee358 to your computer and use it in GitHub Desktop.
Save allenhwkim/2436baaaedd01c5aba203c92fa8ee358 to your computer and use it in GitHub Desktop.
Min. React Example
<!DOCTYPE html>
<html>
<body>
<script src="https://fb.me/react-15.0.0.js"></script>
<script src="https://fb.me/react-dom-15.0.0.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.min.js"></script>
<script type="text/babel">
const style = {
backgroundColor: 'grey',
fontSize: '24px'
};
var HelloWorld = React.createClass({
getInitialState: function() {
return {msg: 0}
},
onClick: function(event) {
this.setState({msg: ++this.state.msg});
},
render: function() {
return (
<div style={style} onClick={this.onClick}>
Hello {this.state.msg}
</div>
);
}
});
ReactDOM.render(
<HelloWorld />,
document.getElementById("hello-world")
);
</script>
<div id="hello-world"></div>
</body>
</html>
@allenhwkim
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment