mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
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:
parent
c2bd2bc935
commit
0197f027f8
1 changed files with 2 additions and 1 deletions
|
|
@ -306,7 +306,8 @@ const TabsList = forwardRef<
|
|||
}, [updateActiveIndicator]);
|
||||
|
||||
useEffect(() => {
|
||||
requestAnimationFrame(updateActiveIndicator);
|
||||
const frameId = requestAnimationFrame(updateActiveIndicator);
|
||||
return () => cancelAnimationFrame(frameId);
|
||||
}, [updateActiveIndicator]);
|
||||
|
||||
const scrollTabToCenter = useCallback((index: number) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue