From 4895a7266d1b7458bc09a77dd6922058a247ea98 Mon Sep 17 00:00:00 2001 From: MAZE Date: Tue, 25 Mar 2025 17:54:12 +0330 Subject: [PATCH] fix: add delay to cipher text --- src/components/cipher.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/cipher.tsx b/src/components/cipher.tsx index 8e705a9..8da5c6d 100644 --- a/src/components/cipher.tsx +++ b/src/components/cipher.tsx @@ -12,10 +12,12 @@ export function CipherText({ interval = 50, text }: CipherTextProps) { const [isMounted, setIsMounted] = useState(false); useEffect(() => { - setIsMounted(true); + setTimeout(() => setIsMounted(true), 2000); }, []); useEffect(() => { + if (!isMounted) return; + let timer: NodeJS.Timeout; if (outputText !== text) { @@ -29,7 +31,7 @@ export function CipherText({ interval = 50, text }: CipherTextProps) { } return () => clearInterval(timer); - }, [text, interval, outputText]); + }, [text, interval, outputText, isMounted]); useEffect(() => { if (outputText === text) {