react-dfp
react-dfp copied to clipboard
Ads are not loading intermittently. Hard refresh works.
Version: 0.17.1
. (Experienced same behavior with 0.11
also)
Ads are rendering as:
<DFPSlotsProvider dfpNetworkId={defaultNetworkID}
collapseEmptyDivs={collapseEmptyDivs}
targetingArguments={targetingArguments}
sizeMapping={adConfig.viewPortSizeMapping}
lazyLoad={lazyLoad}
singleRequest={singleRequest}>
<AdSlot {...adConfig} />
</DFPSlotsProvider>
There's a wrapper component like:
<AdService {...props}/>
where AdService
is wrapping Adslot
with DFPSlotsProvider
as above.
Sometimes I'm getting below error:

More debugging showed me:

It seems like, registeredSlots
have adSlot 3, 4 and 5, but we're still trying to render adSlot 0. Somehow the slots are updated with increased indexes, but the library is unaware of that. I thought maybe in somewhere I'm calling DFPManager.refresh();
but that's not the case.
Any idea why this happening? I spent more than 2 days in this.
hi @asimqt, according what you describe your code is rendering more than one instance of our custom component: AdService
, which ends up in multiple instances of the <DFPSlotsProvider>
, right?.
There should be only one instance of DFPSlotsProvider in the page, declaring more than one will lead to unexpected/buggy behaviors like what you describe.
<DFPSlotsProvider>
<div>
<AdSlot />
...
<AdSlot />
....
</div
</DFPSlotsProvide>
Please update your code so that it follows this pattern and let me know if u still have issues.
Thank you.
Yes. You're correct. I'll rewrite my code and will let you know.