82 lines
1.8 KiB
JavaScript

var Player = React.createClass({
propTypes: {
email: React.PropTypes.string,
id: React.PropTypes.number
},
//getInitialState: function() {
//return {
//id: this.props.id
//email: ""
//};
//},
// componentDidMount: function() {
// $.get(this.props.source, function(result) {
// if (this.isMounted()) {
// console.log("Mounted from player");
// //this.setState({
// //id: result.id
// //email: result.email
// //});
// console.log(result.id);
// this.setProps({
// id: result.id
// });
// }
// }.bind(this));
// },
render: function() {
return (
<div>
<div>Id: {this.props.id}</div>
<div>Email: {this.props.email}</div>
<div>Inventory count: {this.props.inventory_count}</div>
<div><Inventory cards={this.props.inventory} /></div>
</div>
);
}
});
var PlayerList = React.createClass({
// propTypes: {
// players: React.PropTypes.array
// },
// getInitialState: function() {
// return {
// players: []
// };
// },
// componentDidMount: function() {
// $.get(this.props.source, function(result) {
// if (this.isMounted()) {
// this.setState({
// players: result.players
// });
// console.log("Mounted from playerList");
// }
// }.bind(this));
// },
render: function() {
var playerNodes = this.props.players.map(function (player) {
return (
<Player key={player.id} {...player} />
);
});
//<Player key={player.id} id={player.id} email={player.email} inventory_count={player.inventory_count} inventory={player.inventory} />
return (
<div>
PlayerList:
{playerNodes}
</div>
);
}
});