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 ruleP2stack specificStack: React
reactrefstypescripttypes
Use RefObject for object refs; reserve React.Ref for callback-ref flexibility
React.Ref allows both object and callback refs, forcing you to check the type before reading .current. Use React.RefObject<T | null> unless you actually need to accept callback refs.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | inputRef: React.Ref<HTMLInputElement>; // now .current isn't guaranteed |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | inputRef: React.RefObject<HTMLInputElement | null>; // .current is available |
Explanation (EN)
Objašnjenje (HR)