Skip to content

Instantly share code, notes, and snippets.

@orodio
Created January 12, 2015 11:55
Show Gist options
  • Save orodio/112c9d5012d8b60f8405 to your computer and use it in GitHub Desktop.
Save orodio/112c9d5012d8b60f8405 to your computer and use it in GitHub Desktop.
//= require superagent
"use strict";
function poll(fn) {
return superagent.get("/leaderboards/3c3c4514-ac4c-4b45-a054-2a3baa237ac9", fn);
}
var Leaderboard = React.createClass({
getInitialState : function() {
return {
rungs : []
};
},
dealWithResponse: function(res) {
this.setState({rungs: res.body.rungs});
},
componentWillMount: function() {
poll(this.dealWithResponse);
},
render: function() {
var rungs = this.state.rungs.map(function(d) { return <li>{d.player_id}</li>; });
return (
<div className="leaderboard">
{rungs}
</div>
)
}
});
React.render(
<Leaderboard />,
document.getElementById("app")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment