Rendered as Nothing: React's Invisible Values
You'll learn which JavaScript values disappear when rendered in JSX—and why that's actually useful.
The Core Idea
In JSX, when you interpolate null, undefined, true, or false inside curly braces, React renders nothing to the DOM. They're invisible. This isn't a bug—it's a deliberate design choice that makes conditional rendering patterns elegant and safe.
function Example() {
return (
<div>
{null}
{undefined}
{true}
{false}
<p>You only see this paragraph!</p>
</div>
);
}
The output? Just the paragraph. All four values vanish.
Why This Matters
Think of these values as "polite guests" at a dinner party—they show up when invited (no errors) but don't take up any space at the table (no visual output). This makes conditional rendering smooth:
function Greeting({ isLoggedIn }) {
return (
<div>
{isLoggedIn && <p>Welcome back!</p>}
{!isLoggedIn && <p>Please log in</p>}
</div>
);
}
When isLoggedIn is true, the first && expression evaluates to the JSX element (which renders), and the second evaluates to false (which disappears). No awkward "false" text in your UI.
Important Contrast
Numbers do render, including zero:
<div>{0}</div> // Shows "0" on screen
<div>{false}</div> // Shows nothing
This catches beginners off guard with expressions like items.length && <List />, which displays "0" when the array is empty.
Key Takeaway: React silently ignores null, undefined, true, and false in JSX output, enabling clean conditional rendering without visual clutter or errors.