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
reactrefsforwardRefpatterns
Forward refs with forwardRef, not a custom ref prop
Pass refs into a component using React.forwardRef rather than smuggling a ref through a normal prop.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const ThreadRow = ({ loadMoreRef }) => ( |
| 2 | <Card ref={loadMoreRef}>...</Card> |
| 3 | ); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const ThreadRow = React.forwardRef<HTMLDivElement, ThreadRowProps>((props, ref) => ( |
| 2 | <Card ref={ref}>...</Card> |
| 3 | )); |
Explanation (EN)
Objašnjenje (HR)