My personal website
at refactor/vite 17 lines 446 B view raw
1import { useEffect, useState } from "preact/hooks"; 2 3export const ConsoleSpinner = () => { 4 const chars = "|/-\\"; 5 6 const [current, setCurrent] = useState(0); 7 8 useEffect(() => { 9 const i = setInterval( 10 () => setCurrent((current + 1) % chars.length), 11 250, 12 ); 13 return () => clearInterval(i); 14 }, [current, setCurrent]); 15 16 return <span className="font-mono">{chars[current]}</span>; 17};