Skip to content
Justice Tech School

Why Not Index Keys

Index keys break state when a list reorders.

Example
// Risky
items.map((x, i) => <Row key={i} item={x} />);
// Better
items.map((x) => <Row key={x.id} item={x} />);

Exercise

Stable.

key={x.}

Quiz Test

Why avoid index keys?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.