fix: add cancelAnimationFrame cleanup in animated-tabs useEffect

Fixes issue #1093 - requestAnimationFrame was called without cleanup,
causing potential memory leaks and errors when component unmounts before
the frame fires.

- Store frame ID returned by requestAnimationFrame
- Return cleanup function that calls cancelAnimationFrame
This commit is contained in:
universe7creator 2026-04-04 10:56:19 +03:00
parent c2bd2bc935
commit 0197f027f8

View file

@ -306,7 +306,8 @@ const TabsList = forwardRef<
}, [updateActiveIndicator]); }, [updateActiveIndicator]);
useEffect(() => { useEffect(() => {
requestAnimationFrame(updateActiveIndicator); const frameId = requestAnimationFrame(updateActiveIndicator);
return () => cancelAnimationFrame(frameId);
}, [updateActiveIndicator]); }, [updateActiveIndicator]);
const scrollTabToCenter = useCallback((index: number) => { const scrollTabToCenter = useCallback((index: number) => {