Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: prevent duplicated characters in typing animation. (#143)

Joaquin Colaccic1a92fed8d6a
diff --git a/registry/components/magicui/typing-animation.tsx b/registry/components/magicui/typing-animation.tsx
index 20acc14d..8b1a7230 100644
--- a/registry/components/magicui/typing-animation.tsx
+++ b/registry/components/magicui/typing-animation.tsx
@@ -20,7 +20,7 @@ export default function TypingAnimation({
useEffect(() => {
const typingEffect = setInterval(() => {
if (i < text.length) {
- setDisplayedText((prevState) => prevState + text.charAt(i));
+ setDisplayedText(text.substring(0, i + 1));
setI(i + 1);
} else {
clearInterval(typingEffect);