Tsallaka zuwa abun ciki
Justice Tech School

Conditional Rendering

Render different UI with ternaries, && or early returns. Remember that && with 0 renders 0.

Example
function Status({ online }) {
  if (online === undefined) return null;
  return <p>{online ? 'Online' : 'Offline'}</p>;
}

{count > 0 && <Badge n={count} />}

Exercise

Render nothing.

return ;

Quiz Test

What does returning null do?

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