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 ruleP1stack specificStack: react
reacthooksuseeffectcorrectness
Avoid multiple effects with overlapping deps that can fire together
When several effects share dependencies, ensure they don't unintentionally trigger simultaneously and conflict.
PR: vinify-frontend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | useEffect(() => doA(), [query, results]); |
| 2 | useEffect(() => doB(), [query, results]); // both run on every query/results change |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // consolidate or guard so each effect owns a distinct trigger |
| 2 | useEffect(() => { if (shouldRunA) doA(); }, [query]); |
| 3 | useEffect(() => { if (shouldRunB) doB(); }, [results]); |
Explanation (EN)
Objašnjenje (HR)