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
reactfragmentsdommarkup
Use a Fragment instead of a wrapper div when grouping siblings
When you only need to return adjacent elements without an extra DOM node, use a Fragment rather than wrapping them in a meaningless div.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | return ( |
| 2 | <div> |
| 3 | <Header /> |
| 4 | <Body /> |
| 5 | </div> |
| 6 | ); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | return ( |
| 2 | <> |
| 3 | <Header /> |
| 4 | <Body /> |
| 5 | </> |
| 6 | ); |
Explanation (EN)
Objašnjenje (HR)