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
reactlistskeys
Always provide a stable key when rendering lists
Every element produced by a map (and each top-level node of a fragment in a list) needs a key, otherwise React logs missing-key warnings and may mis-reconcile.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | items.map(() => (<><Foo /></>)); |
| 2 | // renderCategory: <div className={style.cat}>...</div> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | items.map((item, i) => (<React.Fragment key={i}><Foo /></React.Fragment>)); |
| 2 | // renderCategory: <div className={style.cat} key={`key-${title}`}>...</div> |
Explanation (EN)
Objašnjenje (HR)