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
reactuseEffectdependenciescorrectness
Depend on the specific field an effect reads, not the whole object
If an effect only uses query.threadId, put query.threadId in the dependency array, not the entire query object, so unrelated query changes don't re-fire it.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | useEffect(() => { |
| 2 | const { threadId } = router.query; |
| 3 | if (threadId) fetchThread(threadId); |
| 4 | }, [router.query]); // re-runs on any query change (filter, page, ...) |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | useEffect(() => { |
| 2 | const { threadId } = router.query; |
| 3 | if (threadId) fetchThread(threadId); |
| 4 | }, [router.query.threadId]); |
Explanation (EN)
Objašnjenje (HR)