Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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