0
Challenge · 103Interview Prep
Debugging Challenges
Interviewused in ~75% of apps
A whole interview format is just a screen of broken React and one question: "what's wrong with this code?" The bugs are always the same six or seven — once you can name them on sight, this round becomes free points.
Core idea. Most React interview bugs are a small, recognizable set: stale closures, missing/empty deps, state mutation, index keys, infinite effect loops, and calling a handler instead of passing it. Learn the symptom-to-cause map and you debug by pattern, not by panic.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
bug 1 / 5 stale closure
Interval always logs 0
useEffect(() => {
const id = setInterval(() => {
console.log(count); // always 0
setCount(count + 1); // stuck at 1
}, 1000);
return () => clearInterval(id);
}, []); // empty depsbroken behavior
press Run to watch the symptom
Predict the broken behavior first, then Run to confirm, then Reveal the one-line fix. Cycle all 5 classics.
↑ play a little first, then dig in