react-key-prop

Enforce stable, unique keys for React list items during reconciliation.

Updated Apr 26, 2026
One-click install
npx skills add https://github.com/suwandre/my-opencode-config --skill react-key-prop-suwandre
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-key-prop
Source: https://github.com/suwandre/my-opencode-config/tree/main/skills/react-key-prop
Command: npx skills add https://github.com/suwandre/my-opencode-config --skill react-key-prop-suwandre

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers avoid React list rendering bugs by enforcing best practices around the key prop. It prevents unstable or missing keys that can cause component state drift during re-renders.

Core Features & Use Cases

  • Use stable, unique IDs from your data for keys.
  • Generate IDs once at data load when IDs are missing.
  • Avoid using array index as keys for dynamic lists; provide safer examples.

Quick Start

Refactor list rendering to use a stable, data-derived id for each item and remove index-based keys.

Frequently Asked Questions about react-key-prop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does using array index as a key prop cause React list rendering bugs?

Using array index as a key prop in React lists causes component state drift during re-renders because changing indices break element identity reconciliation when items are added, removed, or reordered.

How do I generate stable keys for React list items when my data lacks unique IDs?

Generate stable, unique IDs once at data load using a deterministic id generator when your data items lack unique IDs, ensuring reliable React list reconciliation and preventing state drift during dynamic updates.

What is the best way to refactor React list rendering to use stable keys?

The best way to refactor React list rendering is to replace index-based keys with a stable, data-derived id for each item, ensuring correct element identity during reconciliation when items are added, removed, or reordered.

When do I need to enforce stable keys for React component lists?

You need to enforce stable keys for React component lists whenever items may be added, removed, or reordered, as unstable or missing keys cause component state drift and incorrect element identity during reconciliation.

Can I use array index as keys for static React lists that never change?

Array index as keys is discouraged for dynamic React lists where items may be added, removed, or reordered, but static lists with unchanging order are less prone to the component state drift caused by unstable element identity.

Does React key prop enforcement work with lists that have no dependencies?

Yes, React key prop enforcement works without dependencies by requiring data items to supply a stable id or using a deterministic id generator to maintain correct element identity during list reconciliation.