Performance: Map function usage
MEDIUM IMPACT
This affects rendering speed and responsiveness by controlling how many DOM elements React creates and updates.
const items = ['a', 'b', 'c']; return <div>{items.map(item => <div key={item}>{item}</div>)}</div>;
const items = ['a', 'b', 'c']; return <div>{items.map(item => <div>{item}</div>)}</div>;
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Map without keys | High (all items updated) | Many reflows | High paint cost | [X] Bad |
| Map with unique keys | Minimal (only changed items) | Few reflows | Lower paint cost | [OK] Good |
| Map large list without virtualization | Very high (all 1000+ items) | Many reflows | Very high paint cost | [X] Bad |
| Map large list with virtualization | Low (only visible items) | Few reflows | Low paint cost | [OK] Good |