Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Preserve stable identity in React list keys
Use stable unique React keys, preferably domain IDs; shortening a key must not weaken identity.
Bad example
| 1 | {items.map(item => <li key={item.label}>{item.label}</li>)} |
Explanation (EN)
A changing or duplicated label is an unreliable item identity.
Objašnjenje (HR)
Good example
| 1 | {items.map(item => <li key={item.id}>{item.label}</li>)} |
Explanation (EN)
A stable ID survives label changes and item reordering.
Objašnjenje (HR)
Notes (EN)
Prefer a stable domain identifier that is unique among siblings and retains identity when labels change or items reorder.
Exceptions / Tradeoffs (EN)
A short key is not more correct merely because it is short. Index keys are limited to static lists without identity-sensitive updates; do not replace a stable content key with an unstable index.