Skip to content

Commit

Permalink
Fix example from facebook#5870 to avoid double rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 17, 2016
1 parent e09dfe1 commit f5a9a26
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions docs/tips/12-initial-ajax.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ var UserGist = React.createClass({
},

componentDidMount: function() {
this.setState({
serverRequest: $.get(this.props.source, function(result) {
var lastGist = result[0];
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}.bind(this))
});
this.serverRequest = $.get(this.props.source, function (result) {
var lastGist = result[0];
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}.bind(this));
},

componentWillUnmount: function() {
this.state.serverRequest.abort();
this.serverRequest.abort();
},

render: function() {
Expand Down

0 comments on commit f5a9a26

Please sign in to comment.