ResultsContainer.js 897 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react";
  2. import Results from "../components/Results";
  3. import githubHelpers from "../utils/githubHelpers";
  4. const PropTypes = React.PropTypes;
  5. class ResultsContainer extends React.Component {
  6. constructor(props, context, updater) {
  7. super(props, context, updater);
  8. this.state = {
  9. isLoading: true,
  10. scores: []
  11. };
  12. }
  13. componentDidMount() {
  14. githubHelpers.battle(this.props.location.state.playerInfo)
  15. .then((scores) => {
  16. this.setState({
  17. isLoading: false,
  18. scores
  19. });
  20. }).catch((err) => {
  21. console.warn("Error in battle", err);
  22. });
  23. }
  24. render() {
  25. return (
  26. <Results
  27. isLoading={this.state.isLoading}
  28. playerInfo={this.props.location.state.playerInfo}
  29. scores={this.state.scores} />
  30. );
  31. }
  32. }
  33. ResultsContainer.propTypes = {
  34. };
  35. export default ResultsContainer;