I get the ads when i click the button first time. When i trigger the ads next time its showing an error : InterstitialAd.show() The requested InterstitialAd has not loaded and could not be shown
const interstitial = InterstitialAd.createForAdRequest(adUnitId, {
keywords: ['fashion', 'clothing'],
});
const Layout = () => {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
const unsubscribeLoaded = interstitial.addAdEventListener(AdEventType.LOADED, () => {
setLoaded(true);
});
// Start loading the interstitial straight away
interstitial.load();
// Unsubscribe from events on unmount
return () => {
unsubscribeLoaded();
};
}, []);
// No advert ready to show yet
if (!loaded) {
return null;
}
return (
<>
<Button
title="Show Interstitial"
onPress={() => {
interstitial.show();
}}
/>
</>
);
};````