I have a series of React components loading data from HTTP service in componentDidMount as explained here http://facebook.github.io/react/tips/initial-ajax.html
var RandomGist = React.createClass({
getInitialState: function() {
return {
id: '',
url: ''
};
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
var gist = result[Math.round(Math.random() * result.length)];
this.setState({
id: gist.id,
url: gist.html_url
});
}.bind(this));
},
render: function() {
return (
);
}
});
var GistList = React.createClass({
render: function() {
return (
return ;
})}
}
});
var RefreshableGistList = React.createClass({
handleClick: function() {
console.log("Click!");
},
render: function() {
return (
Refresh
);
}
});
React.render(
,
document.body
);
After click on Refresh button I would like to refresh gist from HTTP service. Problem is that setState and forceUpdate will not lead to that because getting data from HTTP service is done in componentDidMount as was explained in original react example.