Skip to content

Commit 08e6ba8

Browse files
committed
Merge pull request #247 from jgoliver/patch-2
Update tutorial.md
2 parents 68ecda2 + 37cf9b3 commit 08e6ba8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

site/jekyll/getting-started/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ var CommentBox = React.createClass({
516516
});
517517
```
518518

519-
Here, `componentDidMount` is a method called automatically by React when a component is rendered. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use [SignalR](http://signalr.net/) or other technologies.
519+
Here, `componentDidMount()` is a method called automatically by React *after* the component is rendered. So, by moving the XMLHttpRequest call from `componentWillMount()`, which is executed only once *before* rendering, to a function called `loadCommentsFromServer()`, we can then call it multiple times from `componentDidMount()` at a set interval to check for any updates to the comments. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use [SignalR](http://signalr.net/) or other technologies.
520520

521521
```javascript{2,15-16,30}
522522
var CommentBox = React.createClass({

0 commit comments

Comments
 (0)