Skip to content

Instantly share code, notes, and snippets.

@arbales
Last active December 17, 2015 21:28
Show Gist options
  • Save arbales/5674453 to your computer and use it in GitHub Desktop.
Save arbales/5674453 to your computer and use it in GitHub Desktop.
<form class="commentForm" onSubmit={this.handleSubmit}>
<input type="text" placeholder="Your name" ref="author" />
<input
type="text"
placeholder="Say something..."
ref="text"
/>
</form>
// tutorial16.js
var CommentForm = React.createClass({
templateName: 'comment_form',
handleSubmit: React.autoBind(function() {
var author = this.refs.author.getDOMNode().value.trim();
var text = this.refs.text.getDOMNode().value.trim();
if (!text || !author) {
return;
}
// TODO: send request to the server
this.refs.author.getDOMNode().value = '';
this.refs.text.getDOMNode().value = '';
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment