ahooks
Version:
react hooks library
14 lines (13 loc) • 379 B
JavaScript
import { useEffect, useState } from 'react';
import useThrottleFn from '../useThrottleFn';
function useThrottle(value, options) {
const [throttled, setThrottled] = useState(value);
const { run } = useThrottleFn(() => {
setThrottled(value);
}, options);
useEffect(() => {
run();
}, [value]);
return throttled;
}
export default useThrottle;