进行纱线启动时出错-回调不是函数

时间:2019-09-04 22:40:04

标签: node.js reactjs

我正在尝试运行我的代码。当我运行时,应用程序加载正常,然后崩溃。我在控制台上看到以下错误。

Uncaught (in promise) TypeError: callback is not a function
    at flushFirstCallback (scheduler.development.js:107)
    at flushImmediateWork (scheduler.development.js:169)
    at unstable_runWithPriority (scheduler.development.js:261)
    at runWithPriority$2 (react-dom.development.js:11305)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11349)
    at flushSyncCallbackQueue (react-dom.development.js:11338)
    at scheduleUpdateOnFiber (react-dom.development.js:21431)
    at Object.enqueueSetState (react-dom.development.js:13100)
    at WithApigeeAuth../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:325)
    at WithApigeeAuth._callee$ (withApigeeAuth.tsx:1)
    at tryCatch (runtime.js:62)
    at Generator.invoke [as _invoke] (runtime.js:288)
    at Generator.prototype.<computed> [as next] (runtime.js:114)
    at asyncGeneratorStep (asyncToGenerator.js:3)
    at _next (asyncToGenerator.js:25)
    at adrum-latest.js:29

我也在粘贴WithApiGeeAuth文件,它在第一行“从“ api”中导入api”中爆炸了;” (请参阅上面的堆栈跟踪)

import api from "api";
import * as React from "react";
import * as TokenManager from "utils/tokenManager";

interface IWithApigeeAuthState {
  readonly isApigeeAuthenticated: boolean;
}

function withApigeeAuth<P>(WrappedComponent: React.ComponentType<P>) {
  /* tslint:disable */
  debugger;
  return class WithApigeeAuth extends React.Component<
    {
      auth: {
        isAuthenticated: () => Promise<boolean>;
        login: (uri: string) => void;
      };
    } & P,
    IWithApigeeAuthState
  > {
    public static displayName = `WithApigeeAuth(${WrappedComponent.name ||
      WrappedComponent.displayName})`;

    public readonly state: IWithApigeeAuthState = {
      isApigeeAuthenticated: false
    };

    public render() {
      return (
        this.state.isApigeeAuthenticated && <WrappedComponent {...this.props} />
      );
    }

    public async componentDidMount() {
      const authenticated = await this.props.auth.isAuthenticated();
      const apigeeSession = TokenManager.getToken();

      if (authenticated && apigeeSession) {
        this.setState(prevState => ({
          ...prevState,
          isApigeeAuthenticated: true
        }));
      }

      if (authenticated && !apigeeSession) {
        const session = await api.auth.fetchSession();
        const apigeeToken = await api.auth.fetchToken(session);

        TokenManager.setToken(apigeeToken);

        this.setState(prevState => ({
          ...prevState,
          isApigeeAuthenticated: true
        }));
      }

      if (!authenticated && apigeeSession) {
        this.setState(prevState => ({
          ...prevState,
          isApigeeAuthenticated: false
        }));
      }

      if (TokenManager.isTokenExpired()) {
        TokenManager.clearToken();
        await this.props.auth.login(window.location.pathname);
      }
    }
  };
}

export default withApigeeAuth;

谁能指出我正确的方向。人们通常说删除Node_Modules,锁定文件并安装。我尝试了所有这些,但是没有用。

0 个答案:

没有答案