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
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.