UNPKG

@taro-hooks/ahooks

Version:
16 lines 501 B
import { useEffect, useState } from '@taro-hooks/core'; import { escapeState } from '@taro-hooks/shared'; import useThrottleFn from '../useThrottleFn'; function useThrottle(value, options) { var _useState = useState(value), throttled = _useState[0], setThrottled = _useState[1]; var throttleFn = useThrottleFn(function () { setThrottled(value); }, options); useEffect(function () { escapeState(throttleFn).run(); }, [value]); return throttled; } export default useThrottle;