var User = React.createClass({ clickHandler: function() { let url = 'http://freecodecamp.com/' + this.props.info.username; window.open(url,'_blank'); }, render: function() { return ( {this.props.index}     {this.props.info.username} {this.props.info.recent} {this.props.info.alltime} ); } }); var Leaderboard = React.createClass({ getInitialState: () => ({board: []}), getRecent: () => $.ajax({ url: 'http://fcctop100.herokuapp.com/api/fccusers/top/recent', method: 'GET' }), componentDidMount: function(){ this .getRecent() .then(board => this.setState({board})) .then(this.sortByRecent); }, sortByRecent: function(opt_board) { this.setState({board: this.state.board.sort((a, b) => b.recent - a.recent)}) $('.sorter:nth-child(3n)').addClass('selected'); $('.sorter:nth-child(4n)').removeClass('selected'); }, sortByTotal: function(opt_board) { this.setState({board: this.state.board.sort((a, b) => b.alltime - a.alltime)}) $('.sorter:nth-child(4n)').addClass('selected'); $('.sorter:nth-child(3n)').removeClass('selected'); }, render: function() { var users = this.state.board.map((user, index) => ()); return (

FreeCodeCamp Leaderboard

{users}
Rank Camper Recent All Time
); } }); ReactDOM.render( , $('background')[0] );