# 1430 MINuseDebounce vs useThrottle
# 14
30 MIN
Overview
Create two custom hooks, useDebounce and useThrottle, to manage the frequency of function executions.
Requirements
- Implement two custom hooks in
hooks.tsuseDebounce(value, delay)- Returns the updated value only after the specified
delayhas passed without further changes.
- Returns the updated value only after the specified
useThrottle(value, limit)- Returns the updated value at most once every
limitmilliseconds, regardless of how many times the original value changes during that period.
- Returns the updated value at most once every
- Both hooks should correctly handle rapid state changes without causing unnecessary re-renders.
Notes
- Only
hooks.tsneeds to be implemented.App.tsxis already complete and should not be modified for functionality. - The exported
DELAYconstant fromApp.tsxcan be changed to observe throttle/debounce behavior.
Tests
- increments debounced and normal counters correctly
- increments throttled and normal counters correctly
- resets debounced and throttled counters instantly on Clear