Skip to content

Commit f44c27e

Browse files
committed
docs: conditionally render NativeAdView
1 parent fde4050 commit f44c27e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/native-ads.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ const NativeComponent = () => {
115115
.catch(console.error);
116116
}, []);
117117

118+
if (!nativeAd) {
119+
return null;
120+
}
121+
118122
return (
119123
<NativeAdView nativeAd={nativeAd}>
120124
// Components to display assets must be placed here
@@ -145,6 +149,10 @@ const NativeComponent = () => {
145149
.catch(console.error);
146150
}, []);
147151

152+
if (!nativeAd) {
153+
return null;
154+
}
155+
148156
return (
149157
<NativeAdView nativeAd={nativeAd}>
150158
<NativeAsset assetType={NativeAssetType.HEADLINE}>
@@ -230,6 +238,10 @@ const NativeComponent = () => {
230238
.catch(console.error);
231239
}, []);
232240

241+
if (!nativeAd) {
242+
return null;
243+
}
244+
233245
return (
234246
// Wrap all the ad assets in the NativeAdView component, and register the view with the nativeAd prop
235247
<NativeAdView nativeAd={nativeAd}>
@@ -285,6 +297,10 @@ const NativeComponent = () => {
285297
};
286298
}, [nativeAd]);
287299

300+
if (!nativeAd) {
301+
return null;
302+
}
303+
288304
return (
289305
<NativeAdView nativeAd={nativeAd}>
290306
// Components to display assets must be placed here
@@ -316,6 +332,10 @@ const NativeComponent = () => {
316332
};
317333
}, [nativeAd]);
318334

335+
if (!nativeAd) {
336+
return null;
337+
}
338+
319339
return (
320340
<NativeAdView nativeAd={nativeAd}>
321341
// Components to display assets must be placed here

0 commit comments

Comments
 (0)