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
reactreact19refsforwardref
Use ref as a prop instead of forwardRef in React 19
On React 19 you can accept ref as a normal prop, so wrapping components in forwardRef (and the associated displayName boilerplate) is unnecessary.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | const Item = forwardRef<HTMLDivElement, ItemProps>(function Item({ ticker }, ref) { |
| 2 | return <div ref={ref}>{ticker}</div>; |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function Item({ ticker, ref }: ItemProps & { ref?: Ref<HTMLDivElement> }) { |
| 2 | return <div ref={ref}>{ticker}</div>; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)