Bring debounce & throttle of lodash version to react-hooks.
useDebounce
& useThrottle
will auto create, update and cancel debounced & throttled instance, so you do not need to cancel manually.
demo
https://frezc.github.io/use-lodash-debounce-throttle/
usage
install
yarn add use-lodash-debounce-throttle
useDebounce
import useDebounce from 'use-lodash-debounce-throttle'; const Com = const debouncedChange = ; return <input ="text" = />
useThrottle
import useThrottle from 'use-lodash-debounce-throttle'; const Com = const debouncedChange = ; return <input ="text" = />
API
- useDebounce: same as https://lodash.com/docs/4.17.11#debounce
- useThrottle: same as https://lodash.com/docs/4.17.11#throttle
DEV
yarn install
yarn start