Skip to content

Commit

Permalink
fix(useThrottleCallback): Cleared timeout on unmount (#1173)
Browse files Browse the repository at this point in the history
Calling clearTimeout is insufficient when checking for undefined. Make sure to set timeout value to
undefined explicitly.
  • Loading branch information
paul-sachs authored Apr 24, 2023
1 parent e3cda00 commit 8681ad8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/useThrottledCallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function useThrottledCallback<Fn extends (...args: any[]) => any>(
useUnmountEffect(() => {
if (timeout.current) {
clearTimeout(timeout.current);
timeout.current = undefined;
}
});

Expand Down

0 comments on commit 8681ad8

Please sign in to comment.