// src/App.jsx
function Cart({ itemCount }) {
return (
{itemCount === 0 &&
Your cart is empty
}
{itemCount > 0 &&
You have {itemCount} item(s) in your cart
}
);
}
function App() {
return (
);
}
export default App;
/*
Notes:
- Using itemCount === 0 and itemCount > 0 (explicit comparisons)
instead of itemCount && ... avoids the classic bug where a plain
0 would render on screen on its own.
- Only one of the two elements ever actually renders for a
given itemCount, since the two conditions are mutually exclusive.
*/