Station 10 · Conditional rendering
A theater does not show every scene every night. Before the bell there is the curtain. After the bell there is the picture. While a reel is playing there is also a marquee announcing what is on. JavaScript decides which of those to draw with a single yes or no, written as a ternary.
Below is the stage and its small script. Flip the status to one of three values. Watch only the matching branch fire and only the matching parts get drawn.
1let status = "intermission";23function Stage() {4return (5status === "intermission" ? <Curtain />6: status === "ready" ? <Picture />7: (8<>9<Picture />10<Marquee />11</>12)13);14}
Set the status — pick a branch
Pick a status. Only the matching branch runs; the others are not drawn at all.
A condition is the boat's fork in the road. status === 'intermission' draws the curtain; otherwise the picture. Branches the condition does not take are not drawn at all — the browser never sees them. That economy is the whole point.