Using if else
let content;
if (isLoggedIn) {
content = <AdminPanel />;
} else {
content = <LoginForm />;
}
return (
<div>
{content}
</div>
);
Using ternary
<div>
{isLoggedIn ? <AdminPanel /> : <LoginForm />}
</div>
Logical &&
Operator
return (
<>
<h1>Todos</h1>
{todos.length == 0 &&
<h2>
No records found
</h2>
}
</>
);