Skip to content

Instantly share code, notes, and snippets.

@mklymyshyn
Created February 25, 2015 18:52
Show Gist options
  • Save mklymyshyn/f979b0600508a94d3d8e to your computer and use it in GitHub Desktop.
Save mklymyshyn/f979b0600508a94d3d8e to your computer and use it in GitHub Desktop.
var React = require('react/addons');
Form = React.createClass({
getInitialState: function () {
return {display: false, name: "", text: ""};
},
send: function (e) {
this.setState({display: true})
},
render: function () {
var display = {display: this.state.display ? "none" : "block"};
return (
<form>
<p style={display}>{this.state.name}: {this.state.text}</p>
<hr />
<div>
<label htmlFor="name">Name:</label>
<input id="name" name="name" value={this.state.name} />
</div>
<div>
<label htmlFor="text">Text:</label>
<textarea id="text" name="text">{this.state.text}</textarea>
</div>
<button type="submit" onClick={this.send}>Send</button>
</form>)
}
});
module.exports = Form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment