Skip to content

Commit 309dcc8

Browse files
committed
refactor: simplify cancel() logic in useDebouncedCallback
1 parent f4bcd87 commit 309dcc8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/useDebouncedCallback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ export default function useDebouncedCallback<
286286
};
287287

288288
func.cancel = () => {
289-
const hadTimer = !!timerId.current;
290-
if (timerId.current) {
289+
const hadTimer = timerId.current;
290+
if (hadTimer) {
291291
useRAF
292292
? cancelAnimationFrame(timerId.current)
293293
: clearTimeout(timerId.current);

0 commit comments

Comments
 (0)