react-next-utils
v1.1.6
Published
Debounce & lazy-load hooks for React/Next.js
Maintainers
Readme
react-next-utils
Debounce & Lazy-load hooks for React and Next.js
A small, highly optimized package to improve performance and user experience in your React/Next.js projects.
Features
useDebounce– Debounce any callback function based on a dependency or input change.useLazyLoad– Trigger callbacks when an element enters the viewport using the Intersection Observer API.
Usage
useDebounce(search, functionCall, 1000);
search- react state whcih is changingfunctionCall-> the function which needs to be called1000- duration
useLazyLoad(ref, functionCall, shouldLoad);ref- ref to a divfunctionCall-> the function which needs to be calledshouldLoad- parameter which decided how long the lazy loading will continue.
Installation
npm install react-next-utils
# or
yarn add react-next-utils