react-dfp icon indicating copy to clipboard operation
react-dfp copied to clipboard

Ads are not loading intermittently. Hard refresh works.

Open asimqt opened this issue 4 years ago • 2 comments

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:

Screenshot 2020-03-02 at 1 14 32 PM

More debugging showed me:

Screenshot 2020-03-02 at 1 15 00 PM

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.

asimqt avatar Mar 02 '20 07:03 asimqt

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.

jaanauati avatar Mar 03 '20 23:03 jaanauati

Yes. You're correct. I'll rewrite my code and will let you know.

asimqt avatar Mar 04 '20 04:03 asimqt