# Rendering Conditional Render

> Rendering Conditional Render is an Agent Skill for development published in the TheOrcDev/8bitcn-ui repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Use explicit ternary operators instead of && for conditional rendering. Apply when rendering values that could be 0, NaN, or other falsy values that might render unexpectedly.

- Skill name: `rendering-conditional-render`
- Category: [Development](https://www.openparable.com/skill/development/1)
- Source: https://github.com/TheOrcDev/8bitcn-ui/blob/HEAD/.claude/skills/rendering-conditional-render/SKILL.md
- Repository: TheOrcDev/8bitcn-ui (1,945 GitHub stars when collected)

## SKILL.md

## 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):**

```tsx
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):**

```tsx
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>
```

---

Source: https://www.openparable.com/skill/development/rendering-conditional-render (OpenParable). Cite the canonical URL above.
