1.0.1 • Published 2 years ago

usethrottle-hook v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

useThrottle hook for React

homepage: https://www.npmjs.com/package/usethrottle-hook;

npm i usethrottle-hook

Usage example

const throttleLoadMore = useThrottle(() => props.loadMore(dataLength), 500);
...
function handleScroll(e: React.UIEvent<HTMLElement>) {
    ...
    let scrollBottom =
        element.scrollHeight - element.offsetHeight - element.scrollTop;
    if (dataLength < countLimit) {
        if (Math.floor(scrollBottom) <= 0) {
        throttleLoadMore();
        
    }
}

}

1.0.1

2 years ago

1.0.0

2 years ago