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
hooksuseCallbackdependenciesexhaustive-deps
Prefer natural callback dependencies over a ref to dodge the lint rule
When a value genuinely affects a callback, list it in the dependency array rather than smuggling it through a ref to silence exhaustive-deps; only use a ref when re-creation must truly be avoided.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | const connect = useCallback(() => { use(tickerIdsRef.current); }, []); // ref to avoid deps |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const connect = useCallback(() => { use(tickerIds); }, [tickerIds]); // depend naturally |
Explanation (EN)
Objašnjenje (HR)