demo git地址:https://git.oschina.net/tomcode/reactdemo.git
var UserGist = React.createClass({
getInitialState: function() {
return {
username: ”,
lastGistUrl: ”
};
},
componentDidMount: function() {
$.get(this.props.source,function(result) {
var lastGist = result[0];
if (this.isMounted()) {
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}
}.bind(this));
},
render: function() {
return (
);
}
});
ReactDOM.render(,document.body );