Performance: Default props
LOW IMPACT
This affects initial component rendering speed and bundle size by how default values are handled.
function Button({ color = 'blue', label }) { return <button style={{ color }}>{label}</button>; }
function Button(props) { const color = props.color || 'blue'; return <button style={{ color }}>{props.label}</button>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline fallback inside render | No extra DOM nodes | Multiple reflows if styles change | Higher paint cost due to recalculations | [X] Bad |
| ES6 default parameters | No extra DOM nodes | Single reflow | Lower paint cost | [OK] Good |