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:
Matt Van Horn 2026-04-08 01:39:14 -07:00
parent 553843ab06
commit 833ea18800

View file

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