diff --git a/packages/core/src/lib/use-prefix.mts b/packages/core/src/lib/use-prefix.mts index c3a631477..850bc1132 100644 --- a/packages/core/src/lib/use-prefix.mts +++ b/packages/core/src/lib/use-prefix.mts @@ -16,20 +16,21 @@ export function usePrefix({ useEffect((): void | (() => unknown) => { if (isLoading) { - const timeout = setTimeout( + let inc = -1; + const interval = setInterval( AsyncResource.bind(() => { - setTick(tick + 1); + inc = inc + 1; + setTick(inc % spinner.frames.length); }), spinner.interval, ); - return () => clearTimeout(timeout); + return () => clearInterval(interval); } - }, [isLoading, tick]); + }, [isLoading]); if (isLoading) { - const frame = tick % spinner.frames.length; - return spinner.frames[frame]!; + return spinner.frames[tick]!; } return prefix;