Limit how frequently a value updates over a fixed interval.
const throttledValue = useThrottle(value, delay);
Raw value: —
Throttled value: —
import { useThrottle } from 'kitzo'; function ScrollTracker() { const [y, setY] = useState(0); const throttledY = useThrottle(y, 200); useEffect(() => { const onScroll = () => setY(window.scrollY); window.addEventListener('scroll', onScroll); return () => window.removeEventListener('scroll', onScroll); }, []); return <p>{throttledY}</p>; }
| Parameter | Type | Description |
|---|---|---|
value | any | The value to throttle |
delay | number | Throttle interval in milliseconds |
Returns the throttled value.