Overview
Create two custom hooks, useDebounce and useThrottle, to manage the frequency of function executions.
Requirements
- Implement two custom hooks:
useDebounce(value, delay)
- Returns the updated value only after the specified
delay has passed without further changes.
useThrottle(value, limit)
- Returns the updated value at most once every
limit milliseconds, regardless of how many times the original value changes during that period.
- Both hooks should correctly handle rapid state changes without causing unnecessary re-renders.
Notes
- Use the
DELAY constant from constants.ts for both hooks.
Tests
- increments debounced and normal counters correctly
- increments throttled and normal counters correctly
- resets debounced and throttled counters instantly on Clear