Building a Tree of UI Components in React with Children or with Self-closing tags

InstructorChris Achard

Share this video with your friends

Send Tweet

You can reuse your custom react components multiple times and build them into a tree of components like this:

<Greeting />
<div>
  <Greeting />
</div>

Notice that the <div> tag contains the Greeting tag as a child, but the Greeting tag contains no children - so it requires the trailing slash (/>) so it can be a "self closing" tag