options.immediate: If true, runs on the first call, then debounces after.
🔁 Methods
debouncedFn.cancel(): Cancels any pending execution
debouncedFn.flush(): Immediately executes the pending function (if any)
🛠 How It Works
Internally, it uses setTimeout and clearTimeout to delay running your function until a certain time has passed since the last call.
📄 License
MIT — free to use and modify.
🧑💼 Why This Matters (Pitch)
I built use-debounce-fn to solve a common UI performance issue in React: when functions like API calls or expensive state updates run too frequently during user input. This hook helps React apps stay fast and efficient — and it’s written in clean, modern TypeScript with developer experience in mind. It demonstrates my understanding of hooks, debouncing logic, and creating reusable tools.