React - Load Initial List via AJAX

Question!

I'm starting to learn react. There's an excellent example in the official docs about loading data initially via AJAX:

var UserGist = React.createClass({
    getInitialState: function() {
        return {
            username: '',
            lastGistUrl: ''
        };
    },

    componentDidMount: function() {
        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.serverRequest.abort();
    },

    render: function() {
        return (
            <div>
                {this.state.username}'s last gist is
                <a href={this.state.lastGistUrl}>here</a>.
            </div>
        );
    }
});

ReactDOM.render(
    <UserGist source="https://api.github.com/users/octocat/gists" />,
    mountNode
);

The code above gets the latest gist of a specific user from GitHub.

What is the best way in React to go about outputting a list of the last 10 gists of the specific user?

How would you modify the code sample above?

By : Muzzstick


This video can help you solving your question :)
By: admin