Last active
August 29, 2015 14:15
-
-
Save proudlygeek/a356d3841e4caf8edc20 to your computer and use it in GitHub Desktop.
test-injection
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> | |
| <head> | |
| <title>Hello React</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script> | |
| </head> | |
| <body> | |
| <div id="main"></div> | |
| <script type="text/jsx" src="main.js"></script> | |
| </body> | |
| </html> |
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
| 'use strict'; | |
| var Hello = React.createClass({ | |
| render: function() { | |
| return (this.props.name !== '') | |
| ? (<div> Hello {this.props.name}!</div>) | |
| : (<div> Hey, tell me your name :( </div>) | |
| } | |
| }); | |
| var App = React.createClass({ | |
| getInitialState: function() { | |
| return { | |
| name: 'world' | |
| }; | |
| }, | |
| onChange: function(e) { | |
| var value = e.target.value; | |
| this.setState({name: value}); | |
| }, | |
| render: function() { | |
| return ( | |
| <div> | |
| <input type="text" onChange={this.onChange} value={this.state.name} /> | |
| <Hello name={this.state.name} /> | |
| </div> | |
| ); | |
| } | |
| }) | |
| React.render(<App />, document.getElementById('main')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment