Some answers are slightly incorrect and point to the wrong part of the docs:
If you want a component to render nothing, just return null
, as per doc:
In rare cases you might want a component to hide itself even though it was rendered by another component. To do this return null instead of its render output.
If you try to return undefined
for example, you'll get the following error:
Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
As pointed out by other answers, null
, true
, false
and undefined
are valid children which is useful for conditional rendering inside your jsx, but it you want your component to hide / render nothing, just return null
.