UNPKG

ahooks

Version:
14 lines (13 loc) 379 B
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;