Tsallaka zuwa abun ciki
Justice Tech School

Debouncing Input

Wait for the user to pause before running a costly action.

Example
function useDebounced(v, ms) {
  const [d, setD] = useState(v);
  useEffect(() => {
    const t = setTimeout(() => setD(v), ms);
    return () => clearTimeout(t);
  }, [v, ms]);
  return d;
}

Exercise

Delay.

setTimeout(fn, )

Quiz Test

What does debounce wait for?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.