Skip to content

Instantly share code, notes, and snippets.

@NeuTrix
Created May 28, 2017 07:44
Show Gist options
  • Save NeuTrix/4f1166d6a6421b6f8dbf24927d32c252 to your computer and use it in GitHub Desktop.
Save NeuTrix/4f1166d6a6421b6f8dbf24927d32c252 to your computer and use it in GitHub Desktop.
React.js Example of a form component
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