var Game = React.createClass({ mixins: [SetIntervalMixin], propTypes: { title: React.PropTypes.string, players: React.PropTypes.array, id: React.PropTypes.number, source: React.PropTypes.string }, getInitialState: function() { return { players: [], title: "" }; }, loadGameFromServer: function() { //console.log(this.props.source); $.get(this.props.source, function(result) { if (this.isMounted()) { //console.log("Mounted"); this.setState({ title: result.title, players: result.players }); } }.bind(this)); }, componentDidMount: function() { this.loadGameFromServer(); this.setInterval(this.loadGameFromServer, 3000); }, render: function() { return (
Title: {this.state.title}
Id: {this.props.id}
Current Player: {this.props.current_player}
); } });