skills/react-key-prop/SKILL.md
Guides proper usage of the key prop in React lists. Use this skill when rendering lists, mapping arrays to components, or troubleshooting list-related state bugs.
npx skillsauth add Chris-Maskey/opencode-config react-key-propInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use stable, unique IDs from your data. Never use array index for dynamic lists.
The key prop provides stable identity to list elements during React's reconciliation process.
Always use unique, stable identifiers directly from your data:
// ✅ Correct
{todos.map((todo) => (
<li key={todo.id}>{todo.text}</li>
))}
Ideal keys are:
When data lacks IDs, create them once when receiving data:
import { nanoid } from 'nanoid';
useEffect(() => {
fetch('/api/items')
.then(res => res.json())
.then(data => {
const itemsWithIds = data.map(item => ({
...item,
_tempId: nanoid() // Stable ID generated once
}));
setItems(itemsWithIds);
});
}, []);
Index as key is acceptable ONLY when ALL conditions are met:
// ❌ WRONG: Creates new key every render
{items.map(item => (
<li key={Math.random()}>{item.name}</li>
))}
This forces React to destroy and recreate all components on every render.
// ❌ WRONG for dynamic lists
{items.map((item, index) => (
<li key={index}>{item.name}</li>
))}
Index fails when:
The bug: Index represents position, not data identity. When positions change but indexes stay the same, React incorrectly "mutates" existing components instead of creating new ones, causing state mismatch.
useId() for List KeysReact's useId() hook is for accessibility (linking labels to inputs), not for generating list keys.
key when rendering listsid from your datananoid/uuid)key during render (Math.random(), Date.now())index as key for dynamic listsuseId() for list keystools
Anti-patterns and mistakes to avoid as a product manager. Use when evaluating leadership behaviors, improving team dynamics, reflecting on management practices, or onboarding new product managers.
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
testing
Design effective CTAs using visual attention and gaze psychology principles. Use when designing landing pages, button hierarchies, conversion elements, or optimizing user attention flow through interfaces.
tools
Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include "Vercel Sandbox browser", "microVM Chrome", "agent-browser in sandbox", "browser automation on Vercel", or any task requiring Chrome in a Vercel Sandbox.