react-native-admob / admob

Admob for React Native with powerful hooks and components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interstistial ad always load on mounted even loadOnMounted = false ??

zoobibackups opened this issue · comments

I try to load interstitial ad on onPress evets but ads are always loaded on mounted. Check my code below

import { useInterstitialAd, TestIds } from '@react-native-admob/admob';

const App = () => {
    const { adLoaded, load} = useInterstitialAd(TestIds.INTERSTITIAL, {
      requestOptions: {
          loadOnMounted: false, // i am not loading ad on mounting
          loadOnDismissed: false
      },
    });

    useEffect(() => {
        if (adLoaded) {
          console.log("Loaded")   /// i never call the load function but still the add is loaded why?????
        }
    },[adLoaded])

   /* rest of the code*/
}

How to resolve this now????
Thanks.

Your option object is wrong. It should be:

{
  loadOnMounted: false,
  loadOnDismissed: false,
  requestOptions:{
    //...
  },
}

They should be declared outside of the requestOptions object.

Your option object is wrong. It should be:

{
  loadOnMounted: false,
  loadOnDismissed: false,
  requestOptions:{
    //...
  },
}

They should be declared outside of the requestOptions object.

My bad, thank you its working now.