From 175758dd3810aaa11792375aafb337d2d58f5ce7 Mon Sep 17 00:00:00 2001 From: Paul Sachs Date: Mon, 27 Mar 2023 17:25:03 -0400 Subject: [PATCH] fix(useThrottleCallback): Cleared timeout on unmount Calling clearTimeout is insufficient when checking for undefined. Make sure to set timeout value to undefined explicitly. --- src/useThrottledCallback/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/useThrottledCallback/index.ts b/src/useThrottledCallback/index.ts index 326ae80c..d64a5105 100644 --- a/src/useThrottledCallback/index.ts +++ b/src/useThrottledCallback/index.ts @@ -28,6 +28,7 @@ export function useThrottledCallback any>( useUnmountEffect(() => { if (timeout.current) { clearTimeout(timeout.current); + timeout.current = undefined; } });