Created
May 28, 2017 07:44
-
-
Save NeuTrix/4f1166d6a6421b6f8dbf24927d32c252 to your computer and use it in GitHub Desktop.
React.js Example of a form component
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
var React = require('react'); | |
var ReactDOM = require('react-dom'); | |
var Input = React.createClass({ | |
getInitialState: function() { | |
return { | |
userInput:"" | |
}; | |
}, | |
handleUserInput: function(e) { | |
this.setState({ | |
userInput: e.target.value | |
}); | |
}, | |
render: function () { | |
return ( | |
<div> | |
<input type="text" onChange={this.handleUserInput} value={this.state.userInput} /> | |
<h1>{this.state.userInput}</h1> | |
</div> | |
); | |
} | |
}); | |
ReactDOM.render( | |
<Input />, | |
document.getElementById('app') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment