Related app/team name (not a must if you want to keep it private): Trucky Overlay but reported from others too (see Slack https://overwolfdevs.slack.com/archives/C2NP5F4BV/p1605906365457400)
Issue Description:
It’s a React app. I have a top level Component (DesktopWindow) containing multiple components. One of them, Profile, contains an ad container. When the component is mounted, initialize the AD SDK injecting it into the body and wait for onload. At onload, call new OwAd with the container to show the ad.
It works.
If i move to another component, e.g. GamesList, so the Profile component, is unmounted and the new one is mounted, when i back to Profile component, so is remounted, calling again new OwAd doesnt show the ad, simply does nothing.
I’ve tried to call removeAd when the Profile component is unmounted or defining a new random container id each time the Profile component is mounted but without results.
It seems there is some kind of limitations to show again an Ad in the same page once the Ad SDK is loaded.
Can you reproduce it (exact steps to reproduce): see above
Impact for my app: [e.g. x% of the users complained about it, it’s a show-stopper]: High, losing ads view
Do you currently have a workaround?
No
See the working code:
Profile.js componentDidMount:
var adDivId = ‘ad-div-’ + Math.random();
this.adsService = new AdsService({ adContainer: adDivId, enableDevelopmentAd: config.ENABLE_TEST_AD, adUnit: AdsUnit.TESTING["400x300_Video"], autoShowAd: true, onAdRemoved: () => this.setState({ adLoaded: false }), onAdRefreshed: () => this.setState({ adLoaded: true }), onDisplayAdLoaded: () => { this.setState({ adLoaded: true }) } });
Profile.js componentWillUnmount
componentWillUnmount() {
this.adsService.removeAd(); this.adDivContainer.current.innerHTML = ""; }
my AdsService implementation: