Skip to content

Instantly share code, notes, and snippets.

@aakashns
Last active October 27, 2015 19:03
Show Gist options
  • Select an option

  • Save aakashns/cf08100b8c10ae54e2e5 to your computer and use it in GitHub Desktop.

Select an option

Save aakashns/cf08100b8c10ae54e2e5 to your computer and use it in GitHub Desktop.
A simple controlled component for Name
import React from 'react';
var Name = React.createClass({
getInitialState: function() {
return { value: "" };
},
onValueChange: function(event) {
this.setState({ value: event.target.value });
},
render: function() {
return (
<div>
<label>Name : </label>
<input type="text" value={this.state.value} onChange={this.onValueChange} />
</div>
);
}
});
export default Name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment