Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP0stack specificStack: react
reactuseEffectinfinite-loopcorrectness
Avoid effect setups that re-trigger themselves into an infinite loop
Be careful that a useEffect does not update state that is in its own dependency chain in a way that re-runs forever.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejavascript
| 1 | useEffect(() => { |
| 2 | setCount(count + 1); |
| 3 | }, [count]); // loops forever |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | useEffect(() => { |
| 2 | setCount(c => c + 1); |
| 3 | }, []); // runs once |
Explanation (EN)
Objašnjenje (HR)