0
Challenge · 14React Core
Conditional Rendering
Coreused in ~100% of apps
Show, hide, or branch UI using plain JavaScript — and dodge the sneaky `0` bug.
Core idea. Choose what to render with && (show or nothing), ternaries (either/or), and early returns (whole-component branches).
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
count2
badge guard
{loggedIn ? <User/> : <Login/>} // → User
{count > 0 && <Badge/>} // → Badge
{liked ? "Liked" : "Like"} // → Like
AAria
cart2
Item 1
Item 2
`count > 0 && <Badge/>` is true, so the badge renders. Flip the toggles to explore each branch.
↑ play a little first, then dig in