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
reactlistskeysperformance
Avoid inline arrows in list rendering; carry data via data attributes
In mapped lists, do not create a new arrow per item to pass row data; use a single handler that reads a data attribute, and always set a stable key.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejsx
| 1 | {items.map(i => ( |
| 2 | <li onClick={() => select(i.id)}>{i.label}</li> |
| 3 | ))} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | const onSelect = e => select(Number(e.currentTarget.dataset.index)); |
| 2 | {items.map(i => ( |
| 3 | <li key={i.id} data-index={i.id} onClick={onSelect}>{i.label}</li> |
| 4 | ))} |
Explanation (EN)
Objašnjenje (HR)