Created
January 12, 2015 11:55
-
-
Save orodio/112c9d5012d8b60f8405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= 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