You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/tutorial.md
+15-19Lines changed: 15 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -301,7 +301,7 @@ React.renderComponent(
301
301
302
302
Now that the data is available in the `CommentList`, let's render the comments dynamically:
303
303
304
-
```javascript{4-6,9}
304
+
```javascript{4-10,13}
305
305
// tutorial10.js
306
306
var CommentList = React.createClass({
307
307
render: function() {
@@ -475,7 +475,7 @@ var CommentForm = React.createClass({
475
475
476
476
Let's make the form interactive. When the user submits the form, we should clear it, submit a request to the server, and refresh the list of comments. To start, let's listen for the form's submit event and clear it.
477
477
478
-
```javascript{3-13,16-17,21}
478
+
```javascript{3-13,16-18}
479
479
// tutorial16.js
480
480
var CommentForm = React.createClass({
481
481
handleSubmit: function() {
@@ -517,7 +517,7 @@ When a user submits a comment, we will need to refresh the list of comments to i
517
517
518
518
We need to pass data from the child component to its parent. We do this by passing a `callback` in props from parent to child:
519
519
520
-
```javascript{15-17,31}
520
+
```javascript{15-17,30}
521
521
// tutorial17.js
522
522
var CommentBox = React.createClass({
523
523
loadCommentsFromServer: function() {
@@ -651,22 +651,18 @@ var CommentBox = React.createClass({
651
651
handleCommentSubmit: function(comment) {
652
652
var comments = this.state.data;
653
653
var newComments = comments.concat([comment]);
654
-
this.setState({data: newComments}, function() {
655
-
// `setState` accepts a callback. To avoid (improbable) race condition,
656
-
// `we'll send the ajax request right after we optimistically set the new
0 commit comments