react-native-google-mobile-ads
    Preparing search index...

    Function useMultiFormatAd

    • Multi-format request as a hook. One request, several eligible formats, one winner (requestCount 1 in v1).

      Ownership, release ordering, never-reject load, load coalescing, and stale-by-policy semantics match usePooledAd. Automatic loading, including when a changed request reloads, is UseMultiFormatAdOptions.autoLoad.

      This hook does not require AdPoolProvider: one request produces one native or GAM banner winner. loaded-partial carries both a usable handle and load-scoped errors; no-fill carries neither handles nor errors. Narrow on status before rendering.

      Returned callbacks have stable identity but use current arguments. With automatic loading enabled, content changes to the request trigger one new load; a freshly allocated content-equal options object does not. Property order is ignored, array order remains significant.

      Parameters

      Returns UseMultiFormatAdResult

      const result = useMultiFormatAd({
      adUnitId: gamUnitId,
      requestOptions: MultiFormatAdPresets.nativeOrBanner([
      BannerAdSize.MEDIUM_RECTANGLE,
      ]),
      autoLoad: consentReady,
      });

      if (result.status === 'no-fill') return <Text onPress={result.retry}>Try again</Text>;
      if (result.status === 'error') return <Text>{result.errors[0]?.reason}</Text>;
      if (result.status === 'stale-by-policy') return <Text onPress={result.retry}>Refresh</Text>;
      const winner = result.ads[0];
      return winner?.format === AdFormat.BANNER
      ? <MultiFormatBannerAdView handle={winner} />
      : winner ? <NativeAdView nativeAd={winner.ad} /> : null;