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 ruleP2universalStack: React
reacthookseffects
Include measured content in effect dependencies when it can change
A measurement effect with an empty dep array will not rerun when its source content updates; depend on the content so it re-measures (or document why a one-shot run is intended).
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | useLayoutEffect(() => { |
| 2 | measure(contentRef.current); |
| 3 | }, []); // never re-measures when content changes |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | useLayoutEffect(() => { |
| 2 | measure(contentRef.current); |
| 3 | }, [content]); |
Explanation (EN)
Objašnjenje (HR)