Skip to content

Commit a228384

Browse files
committed
Fix AdSense initialization robustness in SimpleAd.tsx
1 parent 5a88f48 commit a228384

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/components/ads/SimpleAd.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ export default function SimpleAd({
2626
try {
2727
// Push ad after a delay to ensure DOM is ready
2828
setTimeout(() => {
29-
if (window && (window as any).adsbygoogle && adRef.current) {
29+
if (window && adRef.current) {
30+
(window as any).adsbygoogle = (window as any).adsbygoogle || [];
3031
(window as any).adsbygoogle.push({});
3132
initialized.current = true;
3233
}
3334
}, 500);
3435
} catch (err) {
3536
// Silently fail
37+
console.error("AdSense Error:", err);
3638
}
3739
}, []);
3840

0 commit comments

Comments
 (0)