Feedback

rendering-conditional-render

@theorcdev Claim

Basic information

Repository
TheOrcDev
Skill
rendering-conditional-render

About rendering-conditional-render

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.

rendering-conditional-render is an agent skill listed in the AddMCP.net directory, published by TheOrcDev. Runtime: TypeScript. License: MIT. The repository has 2,061 GitHub stars. Source code is hosted on github.com. Related topics: 8-bit, components, retro, shadcn, ui.

Overview

What is rendering-conditional-render?


name: rendering-conditional-render description: 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.


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 (
{count && {count}}
) } // When count = 0, renders:
0
// When count = 5, renders:
5
``` **Correct (renders nothing when count is 0):** ```tsx function Badge({ count }: { count: number }) { return (
{count > 0 ? {count} : null}
) } // When count = 0, renders:
// When count = 5, renders:
5
```

Comments

No comments yet

Be the first to share feedback about this listing. Sign in to leave a comment.

Sign In

Feedback 💬