GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 12 von 28 · Medien

Conditional rendering

Kostas Diakogiannis

Conditional rendering

Conditional rendering

Sometimes we want to evaluate a boolean value, and based upon it to decide if an element (or even a whole component) will be rendered. There are many ways to do that: Ternary operator, if else statements etc. In this case we will use the && operator that React provides in order to make decisions.

Syntax has to be inside { } as we saw any time we need to evaluate a JS expression inside JSX.

In the case above, the paragraph will be in the DOM only in case showParagraph evaluates to true (has a truthy value).

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck