From 7070074d80d152e54636018de3acf8ddee211aab Mon Sep 17 00:00:00 2001 From: Muneerali199 Date: Sat, 14 Mar 2026 15:02:51 +0530 Subject: [PATCH] fix: clear draggingTimeout on unmount in useTrackpadGesture Add useEffect cleanup to prevent timer memory leak when component unmounts while drag timeout is pending. --- src/hooks/useTrackpadGesture.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hooks/useTrackpadGesture.ts b/src/hooks/useTrackpadGesture.ts index 66f801d8..9fb1583a 100644 --- a/src/hooks/useTrackpadGesture.ts +++ b/src/hooks/useTrackpadGesture.ts @@ -1,4 +1,4 @@ -import { useRef, useState } from "react" +import { useEffect, useRef, useState } from "react" import { PINCH_THRESHOLD, TOUCH_MOVE_THRESHOLD, @@ -254,6 +254,16 @@ export const useTrackpadGesture = ( } } + // Cleanup: clear any pending drag timeout on unmount + useEffect(() => { + return () => { + if (draggingTimeout.current) { + clearTimeout(draggingTimeout.current) + draggingTimeout.current = null + } + } + }, []) + return { isTracking, handlers: {