Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3cee1e

Browse files
petehuntzpao
authored andcommitted
Make state immutable in tutorial (eek)
1 parent d47d509 commit d3cee1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/docs/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ var CommentBox = React.createClass({
629629
},
630630
handleCommentSubmit: function(comment) {
631631
var comments = this.state.data;
632-
comments.push(comment);
633-
this.setState({data: comments});
632+
var newComments = comments.concat([comment]);
633+
this.setState({data: newComments});
634634
$.ajax({
635635
url: this.props.url,
636636
type: 'POST',

0 commit comments

Comments
 (0)