0
Challenge · 15React Core

Lists & Keys

Coreused in ~99% of apps

Render arrays with .map() — and use a stable key, or React will attach state to the wrong row.

Core idea. Map an array to elements and give each a stable, unique key (the item's id, not the array index) so React can track identity across re-renders.
Playground, this isn't a screenshot
AApple
BBerry
MMint
{todos.map((t, i) => <Row key={i} />)}
key = index: looks fine… now press Add to top or Shuffle and watch the star jump to the wrong row.
↑ play a little first, then dig in