maybe fix the useCountUp hook

This commit is contained in:
TFT
2026-03-31 18:41:48 +03:00
parent 4b66bb0001
commit 78950cf19e

View File

@@ -3,13 +3,11 @@
import { useEffect, useRef, useState } from "react";
interface UseCountUpOptions {
end: number;
duration?: number;
suffix?: string;
prefix?: string;
end: number;
duration?: number;
}
export function useCountUp({ end, duration = 2000, suffix = "", prefix = "" }: UseCountUpOptions) {
export function useCountUp({ end, duration = 2000 }: UseCountUpOptions): { ref: React.RefObject<HTMLElement | null>; count: number } {
const [count, setCount] = useState(0);
const [hasStarted, setHasStarted] = useState(false);
const ref = useRef<HTMLElement>(null);
@@ -51,7 +49,5 @@ export function useCountUp({ end, duration = 2000, suffix = "", prefix = "" }: U
requestAnimationFrame(animate);
}, [hasStarted, end, duration]);
const display = `${prefix}${count}${suffix}`;
return { ref, display, count };
return { ref, count };
}