为什么第一次触发后 InterstitialAd 没有加载?

Why is InterstitialAd not loaded after the first trigger?

我设法展示了第一个广告,但下次我尝试触发广告时应用程序崩溃了。并给我这个错误:Error: InterstitialAd.show() The requested InterstitialAd has not loaded and could not be shown

在App.js

componentDidMount() {
    const eventListener = interstitial.onAdEvent(type => {
      if (type === AdEventType.LOADED) {
        this.setState({
          setLoaded: true,
        });
      }
    });

    interstitial.load();
    eventListener();

  }

showAds = () => {
    interstitial.show();
    // No advert ready to show yet
    if (!this.state.loaded) {
      console.log('null');
      return null;
    }
  };

// This trigger is within another function
      this.showAds();

我有一个 class 组件,所以我使用 ComponentDidMount 而不是 useEffect。这可能会引起一些麻烦吗?

更新:

    this.state = {
      loaded: false,
      setLoaded: false,
      Listener: null,
    };

以上状态是重做的尝试

const [loaded, setLoaded] = useState(false);

constructor () {
    super();
    this.Listener=null
  }

componentDidMount() {
    this.Listener = interstitial.onAdEvent(type => {
      if (type === AdEventType.LOADED) {
        this.setState({
          loaded: true,
        });
      }else if(type === AdEventType.CLOSED){
        this.loadAd()
     }
    });
    this.loadAd()
 }

componentWillUnmount(){
  if(this.Listener!==null){
   this.Listener()
  }
}

loadAd = () =>{
   this.setState({
      loaded: false,
   });
   interstitial.load();
}

showAds = () => {
   if (!this.state.loaded) {
     console.log('null');
     return null;
   }else{
     interstitial.show();  
   }
 };