Last active
April 5, 2016 01:02
-
-
Save ryanbrunner/ff8775b7862cc3ef610790121863b20f to your computer and use it in GitHub Desktop.
React Simple App
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script> | |
</head> | |
<body> | |
<div id='hello'></div> | |
<script type='text/jsx'> | |
var HelloWorld = React.createClass({ | |
getInitialState: function() { | |
return { | |
name: this.props.name | |
} | |
}, | |
render: function() { | |
return <div> | |
<div> | |
Who should I say hello to? | |
<input type='text' name='name' value={ this.state.name } onChange={ this.nameChanged } /> | |
</div> | |
Hello, { this.state.name }! | |
</div>; | |
}, | |
nameChanged: function(e) { | |
this.setState({name: e.target.value}); | |
} | |
}); | |
React.render(<HelloWorld name='Ryan' />, document.getElementById("hello")); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment