Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 23, 2024
1 parent 6056f03 commit 590790a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/useDebouncedCallback.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMemo, useRef } from 'react'
import useTimeout from './useTimeout'
import useEventCallback from './useEventCallback'
import useMounted from './useMounted'

export interface UseDebouncedCallbackOptions {
wait: number
Expand Down Expand Up @@ -55,8 +54,6 @@ function useDebouncedCallback<TCallback extends (...args: any[]) => any>(

const isTimerSetRef = useRef(false)
const lastArgsRef = useRef<unknown[] | null>(null)
// Use any to bypass type issue with setTimeout.
const timerRef = useRef<any>(0)

const handleCallback = useEventCallback(fn)

Expand Down Expand Up @@ -170,7 +167,7 @@ function useDebouncedCallback<TCallback extends (...args: any[]) => any>(

if (!isTimerSetRef.current) {
isTimerSetRef.current = true
timerRef.current = timeout.set(timerExpired, wait)
timeout.set(timerExpired, wait)

Check warning on line 170 in src/useDebouncedCallback.ts

View check run for this annotation

Codecov / codecov/patch

src/useDebouncedCallback.ts#L170

Added line #L170 was not covered by tests
}

return returnValueRef.current
Expand Down
2 changes: 1 addition & 1 deletion src/useTimeout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'
import { MutableRefObject, useEffect, useRef, useState } from 'react'
import useMounted from './useMounted'

/*
Expand Down

0 comments on commit 590790a

Please sign in to comment.