Performance: What is a component
MEDIUM IMPACT
This concept affects how quickly the page can render and update UI elements by managing reusable pieces of the interface.
function Title() { return <h1>Title</h1>; } function Description() { return <p>Description</p>; } function ClickButton() { return <button>Click me</button>; } function App() { return ( <div> <Title /> <Description /> <ClickButton /> </div> ); }
function App() { return ( <div> <h1>Title</h1> <p>Description</p> <button>Click me</button> </div> ); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single large component | Many DOM nodes updated at once | Multiple reflows per update | High paint cost due to full re-render | [X] Bad |
| Multiple small components | Only changed components update DOM nodes | Minimal reflows limited to changed parts | Lower paint cost due to partial updates | [OK] Good |