Last active
September 11, 2017 00:46
-
-
Save allenhwkim/2436baaaedd01c5aba203c92fa8ee358 to your computer and use it in GitHub Desktop.
Min. React Example
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
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Plunker Example: http://plnkr.co/edit/6HPNaN?p=preview