Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/useDebounce.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const Demo = () => {
const [
isReady: () => boolean | null,
cancel: () => void,
] = useDebounce(fn: Function, ms: number, deps: DependencyList = []);
] = useDebounce<F extends () => unknown>(fn: F, ms: number, deps: DependencyList = []);
```

- **`fn`**_`: Function`_ - function that will be called;
- **`fn`**_`: F extends () => unknown`_ - function that will be called;
Comment thread
itsmejay80 marked this conversation as resolved.
Outdated
- **`ms`**_`: number`_ - delay in milliseconds;
- **`deps`**_`: DependencyList`_ - array of values that the debounce depends on, in the same manner as useEffect;
- **`isReady`**_`: ()=>boolean|null`_ - function returning current debounce state:
Expand Down
5 changes: 3 additions & 2 deletions src/useDebounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { DependencyList, useEffect } from 'react';
import useTimeoutFn from './useTimeoutFn';

export type UseDebounceReturn = [() => boolean | null, () => void];
export type UseDebounceFn = () => unknown;
Comment thread
itsmejay80 marked this conversation as resolved.
Outdated

export default function useDebounce(
fn: Function,
export default function useDebounce<F extends UseDebounceFn>(
fn: F,
Comment thread
itsmejay80 marked this conversation as resolved.
Outdated
ms: number = 0,
deps: DependencyList = []
): UseDebounceReturn {
Expand Down
Loading