Performance: Event handlers in client components
MEDIUM IMPACT
This affects interaction responsiveness and page load speed by controlling how event listeners are attached and executed in client components.
export default function Button() { const handleClick = () => { console.log('Clicked'); }; return <button onClick={handleClick}>Click me</button>; }
export default function Button() { return <button onClick={() => { console.log('Clicked'); }}>Click me</button>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline arrow function in JSX | No extra DOM nodes | Causes extra React re-renders | Minimal paint impact | [X] Bad |
| Stable handler function reference | No extra DOM nodes | No extra re-renders | Minimal paint impact | [OK] Good |