ConfirmBattleContainer.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from "react";
  2. import ConfirmBattle from "../components/ConfirmBattle";
  3. class ConfirmBattleContainer extends React.Component {
  4. constructor(props) {
  5. console.log("Constructor (getInitialState)");
  6. super(props);
  7. this.state = {
  8. isLoading: true,
  9. playerInfo: []
  10. };
  11. }
  12. componentWillMount() {
  13. console.log("componentWillMount");
  14. }
  15. componentDidMount() {
  16. console.log("componentDidMount");
  17. const query = this.props.location.query;
  18. // Fetch info from Github then update state.
  19. this.setState({
  20. isLoading: true
  21. });
  22. setTimeout(() => { this.setState({ isLoading: false }); }, 2000);
  23. }
  24. componentWillReceiveProps() {
  25. console.log("componentWillReceiveProps");
  26. }
  27. componentWillUnmount() {
  28. console.log("componentWillUnmount");
  29. }
  30. componentWillUpdate(nextProps, nextState) {
  31. console.log("componentWillUpdate: loading ?", nextState.isLoading);
  32. }
  33. render() {
  34. return (
  35. <ConfirmBattle
  36. isLoading={this.state.isLoading}
  37. playerInfo={this.state.playerInfo}
  38. />
  39. );
  40. }
  41. }
  42. ConfirmBattleContainer.contextTypes = {
  43. router: React.PropTypes.object.isRequired
  44. };
  45. export default ConfirmBattleContainer;