React · Junior · Question 52 of 75

How do you render one of two elements depending on a condition?

Explanation

JSX accepts expressions, so ? : works inline. For several branches, compute the element in a variable or a helper function before return.

Further reading

Problem with a question

React · Junior · question 52

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz