From 0197f027f83833dce77163d6b00abb7e3c4aa3e1 Mon Sep 17 00:00:00 2001 From: universe7creator Date: Sat, 4 Apr 2026 10:56:19 +0300 Subject: [PATCH] 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 --- surfsense_web/components/ui/animated-tabs.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/surfsense_web/components/ui/animated-tabs.tsx b/surfsense_web/components/ui/animated-tabs.tsx index 43ae82121..52e2342c9 100644 --- a/surfsense_web/components/ui/animated-tabs.tsx +++ b/surfsense_web/components/ui/animated-tabs.tsx @@ -306,7 +306,8 @@ const TabsList = forwardRef< }, [updateActiveIndicator]); useEffect(() => { - requestAnimationFrame(updateActiveIndicator); + const frameId = requestAnimationFrame(updateActiveIndicator); + return () => cancelAnimationFrame(frameId); }, [updateActiveIndicator]); const scrollTabToCenter = useCallback((index: number) => {