[](https://www.npmjs.org/package/@1ohooks/use-debounce) [](https://coveralls.io/github/1oho
npm install @1ohooks/use-debounce



The @1ohooks/use-debounce package provides a custom React hook for implementing debouncing in your applications.
You can install @1ohooks/use-debounce using npm or yarn:
``sh`
npm install @1ohooks/use-debounceor
yarn add @1ohooks/use-debounce
The useDebounce hook allows you to debounce a function, delaying its execution until after a specified delay period.
`javascript
import { useDebounce } from '@1ohooks/use-debounce';
// Usage example
function MyComponent() {
const [debouncedFunction, cancelDebounce] = useDebounce(() => {
// Your debounced function logic
}, 300);
// Call debouncedFunction to execute the debounced logic
return (
// Your component JSX
);
}
`
#### Parameters
- callback (Function): The function to be debounced.delay
- (number): The delay time in milliseconds before executing the debounced function.options
- (Object, optional): Additional options for customizing the debounce behavior.immediate
- (boolean, optional): If true, the callback will be executed immediately on the leading edge. Default is false.maxWait
- (number, optional): The maximum time in milliseconds to wait between invocations. Default is undefined.
#### Return Values
- debouncedFunction (Function): The debounced function that you should call to trigger the debounced logic.cancelDebounce
- (Function): A function to cancel the debounce and prevent the debounced function from being executed.
- React 16 or higher.
You can use the useDebounce hook in your React components to debounce functions and improve performance. It is particularly useful for handling user input, search requests, and more.
For advanced usage and customization options, refer to the hook documentation.
Thank you for using @1ohooks/use-debounce` to implement debouncing in your React applications. We hope you find it valuable!