Categories
React Answers

Is it Possible to Have React Components that Doesn’t Render HTML?

Spread the love

Sometimes, we don’t want to render HTML in our React component.

In this article, we’ll look at which values React components can render other than HTML.

Is it Possible to Have React Components that Doesn’t Render HTML?

It’s possible to render values other than HTML in a component.

We can render one of the following values if we don’t a React component to render anything:

false
null
[]
<React.Fragment></React.Fragment>
<></>

We can render false, null, an empty array or an empty fragment in our component.

However, we can’t render undefined.

Conclusion.

It’s possible to render values other than HTML in a component.

We can render false, null, an empty array or an empty fragment in our component.

However, we can’t render undefined.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *