React Output Prediction Medium +20 XP
Conditional Rendering
What renders when isLoggedIn is false?
ReactRead-only
function App({ isLoggedIn }) {
return isLoggedIn ? <Dashboard /> : <Login />;
}What is the output?
Show answer and explanation
Answer: <Login />
The ternary operator renders <Dashboard /> when true and <Login /> when false. isLoggedIn is false so Login renders.
Hint: Ternary: condition ? ifTrue : ifFalse.
What this challenge tests
Output Prediction in React: conditional-rendering, ternary.