Add Generic Fn for useDebounce

Open Beginner friendly
#2,677 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
react, typescript
Domain
frontend

Research direction

Start at the useDebounce hook entry point and compare its current typing with the generic signature shown here. Confirm the change through the project's TypeScript validation; done means the returned function preserves the input function's parameter and return types.

Written by the indexing model from the issue text.

Description

For useDebounce hook add type parameter for returned Function.

Example:

const useDebounce = <F extends (...args: any[]) => any>(
	func: F,
	wait: number = 0,
): F => {
	return useMemo<F>(() => debounce(func, wait), [func, wait]);
};
Dominant language
TypeScript
Stars
44k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from streamich/react-use

All issues in streamich/react-use

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.