React Conditional Render
Conditional rendering in React works the exact same way conditions work in JavaScript. Use JavaScript operators like if or the conditional operator (ternary) to create elements representing the current state, and let React update the UI to match them.
if / Early Returns
You can use a standard if statement to conditionally return JSX. If the condition is met, the component returns the markup and "exits" early, so the rest of the component isn't processed.
Ternary Operator (? :)
Since you cannot put an `if` statement *inside* a JSX return block, you use the ternary operator. It takes a condition followed by a question mark (?), then the expression to execute if truthy, a colon (:), and the expression if falsy.
Logical AND (&&) and the "0" Trap
If you only want to render something if true, and nothing if false, use &&. But beware! While React ignores boolean false, it does render the number 0. If you check array.length && <Div/> and length is 0, React will literally print a "0" on the page! Convert it to a boolean first: array.length > 0 && ...
View React Ignore Rules+
In JSX, the following values render nothing:null, undefined, true, and false. However, 0, NaN, and empty strings "" might be handled differently depending on DOM placement, but 0 specifically is converted to a text node and displayed. Always ensure the left-hand side of an && expression is a strict boolean!
