mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 19:36:25 +02:00
fix: add cancelAnimationFrame cleanup in animated-tabs useEffect
Store the requestAnimationFrame ID and cancel it on unmount to prevent updateActiveIndicator from running on an unmounted component. Fixes #1093
This commit is contained in:
parent
553843ab06
commit
833ea18800
1 changed files with 2 additions and 1 deletions
|
|
@ -310,7 +310,8 @@ const TabsList = forwardRef<
|
||||||
}, [updateActiveIndicator]);
|
}, [updateActiveIndicator]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
requestAnimationFrame(updateActiveIndicator);
|
const id = requestAnimationFrame(updateActiveIndicator);
|
||||||
|
return () => cancelAnimationFrame(id);
|
||||||
}, [updateActiveIndicator]);
|
}, [updateActiveIndicator]);
|
||||||
|
|
||||||
const scrollTabToCenter = useCallback((index: number) => {
|
const scrollTabToCenter = useCallback((index: number) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue