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
reactlistsrenderingdefensive
Cap rendered list length explicitly with slice
When a section should show at most N items, slice(0, N) before mapping so extra data never overflows the layout.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | {listingItems.map((item, i) => <ListingItem key={i} {...item} />)} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {listingItems.slice(0, 3).map((item, i) => <ListingItem key={i} {...item} />)} |
Explanation (EN)
Objašnjenje (HR)