useEffect(() => { const eventListener = interstitial.onAdEvent(type => { if (type === AdEventType.LOADED) { setLoaded(true); } if (type === AdEventType.CLOSED) { console.log("ad closed"); setLoaded(false); //reload ad interstitial.load(); } }); // Start loading the interstitial straight away interstitial.load(); // Unsubscribe from events on unmount return () => { eventListener(); }; }, []);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter