Browse Source

Fix example from #5870 to avoid double rendering

main
Simen Bekkhus 9 years ago
parent
commit
3b4b99710f
  1. 18
      tips/12-initial-ajax.md

18
tips/12-initial-ajax.md

@ -23,19 +23,17 @@ var UserGist = React.createClass({
}, },
componentDidMount: function() { componentDidMount: function() {
this.setState({ this.serverRequest = $.get(this.props.source, function (result) {
serverRequest: $.get(this.props.source, function(result) { var lastGist = result[0];
var lastGist = result[0]; this.setState({
this.setState({ username: lastGist.owner.login,
username: lastGist.owner.login, lastGistUrl: lastGist.html_url
lastGistUrl: lastGist.html_url });
}); }.bind(this));
}.bind(this))
});
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
this.state.serverRequest.abort(); this.serverRequest.abort();
}, },
render: function() { render: function() {

Loading…
Cancel
Save