2
0

index.jsx 885 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React, { Component } from "react";
  2. import PropTypes from "prop-types";
  3. import { connect } from "react-redux";
  4. import { ban, authenticate } from "actions/app";
  5. import Menu from "components/Global/Menu";
  6. import io from "../../io";
  7. import config from "../../../../config/default";
  8. @connect()
  9. export default class App extends Component {
  10. static propTypes = {
  11. children: PropTypes.object,
  12. dispatch: PropTypes.func,
  13. }
  14. componentDidMount() {
  15. const { dispatch } = this.props;
  16. io.init(config.serverDomain);
  17. io.getSocket(socket => {
  18. socket.on("ready", (status, role, username, userId) => {
  19. dispatch(authenticate({ status, role, username, userId }));
  20. });
  21. socket.on("keep.event:banned", reason => dispatch(ban(reason)));
  22. });
  23. }
  24. render() {
  25. const { children } = this.props;
  26. return (
  27. <div>
  28. <Menu />
  29. <div>{ children }</div>
  30. </div>
  31. );
  32. }
  33. }