Performance: Functional components
MEDIUM IMPACT
This affects initial page load speed and interaction responsiveness by how React renders and updates UI components.
function Button({ label }) { return <button>{label}</button>; }
class Button extends React.Component { render() { return <button>{this.props.label}</button>; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Class component with instance | More nodes due to lifecycle wrappers | Multiple reflows if state changes trigger full re-renders | Higher paint cost due to extra DOM updates | [X] Bad |
| Functional component with hooks | Minimal nodes, direct function calls | Single reflow per state change | Lower paint cost due to optimized updates | [OK] Good |