From 3b49211aab0e6f8af487ab17dfc80b2bce3c9227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Fri, 20 Mar 2026 01:40:06 +0300 Subject: [PATCH] refactor(components): update EzoicPlaceholder to optimize DOM handling --- src/components/ads/ezoic-placeholder.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/ads/ezoic-placeholder.tsx b/src/components/ads/ezoic-placeholder.tsx index c0a80527..15318083 100644 --- a/src/components/ads/ezoic-placeholder.tsx +++ b/src/components/ads/ezoic-placeholder.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect } from "react"; import { useTranslations } from "next-intl"; import { runEzoic } from "@/lib/ezoic"; @@ -10,18 +10,15 @@ interface EzoicPlaceholderProps { /** * Manages the lifecycle of a single Ezoic ad slot. - * Renders the placeholder only after mount so the DOM element exists - * when showAds() is called. Destroys the placeholder on unmount. + * The placeholder div is always in the DOM so Ezoic can find it + * when showAds() runs. Destroys the placeholder on unmount. * * @see https://docs.ezoic.com/docs/ezoicadsadvanced/nextjs/ */ export function EzoicPlaceholder({ id }: EzoicPlaceholderProps) { const t = useTranslations("common"); - const [isRendered, setIsRendered] = useState(false); useEffect(() => { - setIsRendered(true); - runEzoic(() => { window.ezstandalone?.showAds(id); }); @@ -40,7 +37,7 @@ export function EzoicPlaceholder({ id }: EzoicPlaceholderProps) { {t("ad")} - {isRendered &&
} +
); }