Components are the fundamental building blocks of React. In fact, components are the vocabulary of JSX markup. In this section, we'll see how to encapsulate HTML markup within a component. We'll build examples that nest custom JSX elements and learn how to namespace your components.
Encapsulating HTML
We create new JSX elements so that we can encapsulate larger structures. This means that instead of having to type out complex markup, you can use your custom tag. The React component returns the JSX that goes where the tag is used. Let's look at the following example:
import React, { Component } from 'react';
import { render } from 'react-dom';
class MyComponent extends Component {
render() {
return (
<section>
<h1>My Component</h1>
<p>Content in my component...</p>
</section>
);
}
}
render(<MyComponent />, document.getElementById('root'));
Here...