Created
February 25, 2015 18:52
-
-
Save mklymyshyn/f979b0600508a94d3d8e to your computer and use it in GitHub Desktop.
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/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