TableOfMoves.js 921 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react/addons';
  2. import GameStore from '../stores/GameStore';
  3. import onGameChange from '../mixins/onGameChange';
  4. const TableOfMoves = React.createClass({
  5. mixins: [React.addons.PureRenderMixin, onGameChange],
  6. getInitialState() {
  7. return {
  8. moves: GameStore.getMoves()
  9. };
  10. },
  11. render() {
  12. return (
  13. <table id="moves" className="clearfix">
  14. <tbody>
  15. {this.state.moves.map((row, i) => (
  16. <tr key={i}>
  17. <td>
  18. <strong>{`${i + 1}.`}</strong>
  19. </td>
  20. {row.map((move, j) => (
  21. <td key={j}>
  22. <span>{move}</span>
  23. </td>
  24. )).toArray()}
  25. </tr>
  26. )).toArray()}
  27. </tbody>
  28. </table>
  29. );
  30. },
  31. _onGameChange() {
  32. this.setState({
  33. moves: GameStore.getMoves()
  34. });
  35. }
  36. });
  37. export default TableOfMoves;