const pool = AdPoolPresets.display(gamUnitId, {
bannerSizes: [BannerAdSize.MEDIUM_RECTANGLE],
});
function Placement() {
const { status, ad, poll } = usePooledAd(pool.poolId);
return (
<>
<Button title="Load placement" disabled={status === 'polling'} onPress={() => void poll()} />
{ad?.format === AdFormat.BANNER ? <MultiFormatBannerAdView handle={ad} /> : null}
</>
);
}
<AdPoolProvider pools={[pool]} enabled={consentReady}>
<Placement />
</AdPoolProvider>;
Declarative pool ownership. Creates pools for the configs it is given and destroys them on unmount, reconciling by
poolIdon every render rather than by array identity.Renders
childrenunchanged and keeps no React state: it is not a context provider, so it never subscribes to the pool registry. Consumers read pool state throughuseAdPool/usePooledAd, which subscribe individually; a registry subscription here would re-render the whole subtree every time any pool registered or was destroyed.The provider owns pools, not ads already handed to consumers:
poolIdvalues.useAdPoolorusePooledAd.A new
poolsarray with unchanged ids/configs does not recreate native pools;useMemois an optimization, not a correctness requirement.Creating a pool initializes the SDK on Android and starts preloading, so pass
enabled={consentReady}until consent is resolved.enabled={false}stops future creates only; it never tears down existing pools.