Skip to content

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Sep 26, 2023
1 parent 6c8e509 commit 8bdb0a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/hooks/src/useDebounceFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import isDev from '../utils/isDev';

type noop = (...args: any[]) => any;

function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
function useDebounceFn<T extends noop>(fn: T, options: DebounceOptions = {}) {
if (isDev) {
if (!isFunction(fn)) {
console.error(`useDebounceFn expected parameter is a function, got ${typeof fn}`);
Expand All @@ -17,7 +17,8 @@ function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {

const fnRef = useLatest(fn);

const wait = options?.wait ?? 1000;
// https://github.com/alibaba/hooks/issues/2331
const wait = 'wait' in options ? options.wait : 1000;

const debounced = useMemo(
() =>
Expand Down

0 comments on commit 8bdb0a7

Please sign in to comment.