Creating your own JSX elements
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 show you how to nest custom JSX elements and how to namespace your components.
Encapsulating HTML
The reason that we want to create new JSX elements is so that we can encapsulate larger structures. This means that instead of having to type out complex markup, we just use our custom tag. The React component returns the JSX that replaces the element. Let's look at an example now:
// We also need "Component" so that we can // extend it and make a new JSX tag. import React, { Component } from 'react'; import { render } from 'react-dom'; // "MyComponent" extends "Component", which means that // we can now use it in JSX markup. class MyComponent extends Component { render() { ...