Performance: Logical AND rendering
MEDIUM IMPACT
This affects how React decides to render parts of the UI, impacting rendering speed and interaction responsiveness.
return (
<div>
{condition && <ExpensiveComponent />}
</div>
);return (
<div>
<ExpensiveComponent show={condition} />
</div>
);| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Component with show={condition} | Always reconciles component instance | Potential multiple reflows if toggled | Higher paint cost due to extra lifecycle | [!] OK |
| Logical AND rendering | Skips rendering when false | Fewer reflows as DOM updates are minimized | Lower paint cost | [OK] Good |