react-route,react-hot-loader.webpack (You cannot change ; it will be ignored)

后端 未结 7 1332
有刺的猬
有刺的猬 2021-02-13 13:16

it\'s my first project that use react,react-router,react-hot-loader,webpack-dev-server and webpack. when I chang

7条回答
  •  清酒与你
    2021-02-13 13:37

    My Solution is change "Reflux.Component" to "React.Component"

    class AppRouter extends Reflux.Component {
      constructor(props){
        super(props);
        this.store = AuthStore;
      }
      requireAuth (nextState, replace, callback) {
    
        if (nextState.location.pathname != '/login' && nextState.location.pathname != '/logout') {
          ActionsAuth.jwt.refresh();
        }
        const token = UtilsJWT().getToken();
        if (token){
          if (nextState.location.pathname == '/login') {
    
            window.location.href = '/main';
          }
          callback();
        }else{
          if (nextState.location.pathname != '/login') {
          window.location.href = '/login';
          }
        }
      }
      verifyAuth (nextState, replace, callback) {
        const token = UtilsJWT().getToken();
        if (token){
          if (nextState.location.pathname == '/login') {
    
            window.location.href = '/main';
          }
          callback();
        }else{
          if (nextState.location.pathname != '/login') {
            window.location.href = '/login';
          }
          callback();
        }
      }
    
      render(){
        return (
          
              
                  
                  
                  
                  
                  
                  
              
          
        )
      }
    }

提交回复
热议问题