Files
aiworker/.gemini/skills/vercel-react-best-practices/rules/rendering-conditional-render.md
Hector Ros dcaaef1011 Unify past-sessions naming format
Format: YYYY-MM-DD-description.md
- 2026-01-19-infrastructure-deployment.md
- 2026-01-19-backend-api-implementation.md (in progress)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-01-20 01:07:17 +01:00

980 B

title, impact, impactDescription, tags
title impact impactDescription tags
Use Explicit Conditional Rendering LOW prevents rendering 0 or NaN rendering, conditional, jsx, falsy-values

Use Explicit Conditional Rendering

Use explicit ternary operators (? :) instead of && for conditional rendering when the condition can be 0, NaN, or other falsy values that render.

Incorrect (renders "0" when count is 0):

function Badge({ count }: { count: number }) {
  return (
    <div>
      {count && <span className="badge">{count}</span>}
    </div>
  )
}

// When count = 0, renders: <div>0</div>
// When count = 5, renders: <div><span class="badge">5</span></div>

Correct (renders nothing when count is 0):

function Badge({ count }: { count: number }) {
  return (
    <div>
      {count > 0 ? <span className="badge">{count}</span> : null}
    </div>
  )
}

// When count = 0, renders: <div></div>
// When count = 5, renders: <div><span class="badge">5</span></div>