Skip to content
Justice Tech School

Conditional Rendering

Use ternaries and && to show content conditionally.

Example
function Status({ online }) {
  return (
    <div>
      {online ? <b>Online</b> : <i>Offline</i>}
      {online && <span>Welcome</span>}
    </div>
  );
}

Exercise

Show only if true.

{ok  <p>Yes</p>}

Quiz Test

What does && render when false?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.