import React, { Component } from 'react' import { connect } from 'react-redux' import PropTypes from 'prop-types' import { Route, HashRouter, Redirect, Switch } from 'react-router-dom' import { Home, ProjectGroups, Interface, News, AddInterface } from './containers/index' import User from './containers/User/User.js' import Header from './components/Header/Header' import { checkLoginState } from './actions/login' const LOADING_STATUS = 0; const GUEST_STATUS = 1; // const MEMBER_STATUS = 2; class App extends Component { constructor(props) { super(props); this.state = { login: LOADING_STATUS } } static propTypes = { checkLoginState:PropTypes.func, loginState:PropTypes.number } route = (status) => { let r; if (status === LOADING_STATUS) { return loading... } else if (status === GUEST_STATUS) { r = (
) } else { r = (
) } return r } componentDidMount() { this.props.checkLoginState(); } render() { return this.route(this.props.loginState) } } export default connect( state => { return{ loginState:state.login.loginState } }, { checkLoginState } )(App)