useEffect deps Playground

Mr. Harun’s count on the neighbourhood head’s screen: a real useEffect starts a setInterval, pick the deps [], [count], [opsi] or none, then the order of…

Why it matters

useEffect deps are React’s number one bug source. Knowing why an interval uses an old value ([]) or why your app renders forever (no array) is the difference between a two-minute debug and a two-hour one.

The key idea

The deps decide WHEN the effect runs again, and which values it holds

Common mistakes

Try it in this playground