update: 更新依赖 删除shadcn
This commit is contained in:
1 parent
812f0b291f
commit
4725e373c2
3 files changed
+418
-3621
No files matched your search
@@ -6,14 +6,18 @@ export function useTypewriter(text: string, speed = 100) {
|
||||
|
||||
useEffect(() => {
|
||||
let i = 0;
|
||||
setDisplayed("");
|
||||
|
||||
const timer = setInterval(() => {
|
||||
i++;
|
||||
setDisplayed(text.slice(0, i));
|
||||
if (i === text.length) clearInterval(timer);
|
||||
|
||||
if (i === text.length) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, speed);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
}, [text, speed]);
|
||||
|
||||
return displayed;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user