React Throttling — Build a Rate-Limited Like Button

Custom Hooks — Intermediate React challenge.

Build a generic leading-edge useThrottle hook, then wire it up to a rate-limited Like button — clicks fire instantly the first time, then get silently ignored until a cooldown passes, split across a hook file and a component file.

Requirements

Signature

function useThrottle<T extends (...args: any[]) => void>(callback: T, delay: number): T
function LikeButton(): JSX.Element

Example

const throttledLike = useThrottle(handleLike, 1000);
// click x4 rapidly -> handleLike fires only once
// wait 1000ms, click again -> handleLike fires a second time

Constraints

🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code
Loading workspace…