React · Junior · Question 53 of 75

What should a component return to render nothing?

Explanation

Returning null renders nothing but the component still exists (its hooks and state live on). Since React 18, returning undefined is also allowed but null is clearer.

Further reading

Problem with a question

React · Junior · question 53

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