Josh Russo
Josh Russo

Reputation: 3241

How do you create a React tag component that conditionally displays the child elements it wraps?

I want to create a component in React that I can use to wrap other tags and either display those child tags or alternate default content. A classic example is an authentication tag, that only shows the content after the user logs in.

What is this referred to in React and how do I get access to the child tags to show them or not?

Upvotes: 0

Views: 282

Answers (1)

Deadron
Deadron

Reputation: 5289

You should read the documentation available about the children property. https://reactjs.org/docs/composition-vs-inheritance.html

Upvotes: 1

Related Questions