mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
fix(react): Add cancelAnimationFrame cleanup in useEffect
- Add cleanup function to cancel animation frame on unmount - Prevents potential memory leaks and setState on unmounted component - Closes #1093
This commit is contained in:
parent
c2bd2bc935
commit
805eacb9fc
3 changed files with 18 additions and 5 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