Performance: Avoiding unnecessary renders
HIGH IMPACT
This concept affects how fast the UI updates and how responsive the app feels during user interactions.
const Item = React.memo(function Item({ data }) { console.log('Render:', data.id); return <div>{data.name}</div>; }); function ItemList({ items }) { return items.map(item => <Item key={item.id} data={item} />); }
function ItemList({ items }) { return items.map(item => <Item key={item.id} data={item} />); } function Item({ data }) { console.log('Render:', data.id); return <div>{data.name}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Without memoization | Many unnecessary DOM updates | Many reflows triggered | High paint cost due to frequent updates | [X] Bad |
| With React.memo | Only necessary DOM updates | Minimal reflows | Lower paint cost with fewer updates | [OK] Good |