ReactConditional Rendering

In React, you can render elements conditionally using JavaScript operators like if, ? : (ternary), or logical &&.

This is useful when showing or hiding parts of the UI based on certain conditions.

function UserGreeting({ isLoggedIn }) {
  return (
    <div>
      {isLoggedIn ? <h1>Welcome back!</h1> : <h1>Please log in.</h1>}
    </div>
  );
}