Join our Newsletter — 33% off our NHI Course
Architecture & Implementation

Key Prop

← Back to Glossary
By NHI Mgmt Group Updated September 29, 2026 Domain: Architecture & Implementation

A key prop is the identifier React uses to track items in a list across renders. Stable keys help React match elements to the correct component instance during reconciliation. If keys are missing, unstable, or based on array position, React may misapply state when items are reordered, added, or removed.

What a key prop actually does

In React, a key prop gives each item in a rendered list a stable identity across renders. That identity helps the reconciliation process determine which component instance should be updated, reused, or removed when list order changes.

Keys are not visible UI content and they are not general-purpose IDs for your application data. Their job is to help React preserve the relationship between rendered elements and component state.

Why stable keys matter

Stable keys reduce the chance that React will treat one item as if it were another. When keys are derived from durable data, React can track inserts, deletes, and reordering more accurately, which keeps local state attached to the right item.

Unstable keys, especially array indexes in dynamic lists, can cause state to move unexpectedly between rows. That can produce subtle UI defects such as edited values appearing under the wrong item, focus jumping, or stale component state surviving longer than it should.

How React uses keys during reconciliation

During reconciliation, React compares the previous render with the next one and uses keys to match siblings in a list. A matching key tells React that the element represents the same logical item, even if its position in the array changed.

When a list item keeps the same key, React can preserve component state and avoid unnecessary remounts. When the key changes, React treats the element as a different instance, which is useful only when you truly want to reset that subtree.

Common mistakes and better patterns

The most common mistake is using the array index as a key in a list that can reorder, filter, insert, or delete items. That pattern is only safe when the list is static and the item order never changes.

A better pattern is to use a stable identifier from the underlying data, such as a database ID, UUID, or other durable item identifier. If no natural ID exists, the data model usually needs one before the UI can track items reliably.

Risk and Threat Considerations

Incorrect keys are usually a correctness problem first, but they can become a trust and integrity issue in stateful interfaces. If state is misapplied across rows, users may act on the wrong record, submit the wrong edit, or misread which item was actually changed.

Failure mechanism: React reuses component instances based on the key, so unstable or duplicate keys can attach preserved state, event handlers, or local input values to the wrong list item after a reorder or filter.

Impact: The UI can silently display misleading data, corrupt user actions, or create hard-to-detect bugs that only appear when list structure changes.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV15 — Secure Coding and ArchitectureKey choice affects component state integrity in rendered UI lists.
Recommendation — Use stable identifiers for list items to preserve component state across renders.
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationCorrect item identity prevents unintended state and data handling in UI input flows.
Recommendation — Validate list item identity so UI updates apply to the intended record.
CIS Controls v8CIS-16 — Application Software SecurityReact key usage is a frontend application security and correctness concern.
Recommendation — Review frontend list rendering patterns to prevent state mismatch bugs.

Practitioner Guidance

What to watch for: Treat key choice as part of component correctness, not a cosmetic implementation detail. If a list can change order or membership, use a stable item identifier and verify that the key stays consistent for the same logical record across renders.

Practitioner takeaway: If the key changes when the item has not meaningfully changed, React will likely treat it as a different component and your UI state may drift.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 29, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org