|
@@ -42,13 +42,23 @@ let CommentForm = React.createClass({
|
|
handleAuthorChange: function (e) {
|
|
handleAuthorChange: function (e) {
|
|
this.setState({ author: e.target.value });
|
|
this.setState({ author: e.target.value });
|
|
},
|
|
},
|
|
|
|
+ handleSubmit: function (e) {
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ let author = this.state.author.trim();
|
|
|
|
+ let text = this.state.text.trim();
|
|
|
|
+ if (!text || !author) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // TODO send request to the server.
|
|
|
|
+ this.setState({ author: '', text: '' });
|
|
|
|
+ },
|
|
handleTextChange: function (e) {
|
|
handleTextChange: function (e) {
|
|
this.setState({ text: e.target.value });
|
|
this.setState({ text: e.target.value });
|
|
},
|
|
},
|
|
render: function () {
|
|
render: function () {
|
|
return (
|
|
return (
|
|
<div className="commentForm">
|
|
<div className="commentForm">
|
|
- <form className="commentForm">
|
|
|
|
|
|
+ <form className="commentForm" onSubmit={this.handleSubmit}>
|
|
<input
|
|
<input
|
|
type="text"
|
|
type="text"
|
|
placeholder="Your name"
|
|
placeholder="Your name"
|