A shop page with twenty product cards: do you really write the card's JSX twenty times? No. You write the card once, give it a name, and use it wherever you need it. A named piece of UI you can use again and again is called a component.
In React, a component is an ordinary JavaScript function whose name starts with a capital letter and that returns JSX. A component is like a rubber stamp: made once, stamped many times, and every print is exactly the same. Change the stamp's design, and every print after that changes too. The stamp is the component's function, and each print is the UI that appears in each place where the component is used.
Make a component, then use it
This is the Greeting component, used three times inside App:
function Greeting() {
return <p>Welcome!</p>
}
function App() {
return (
<div>
<Greeting />
<Greeting />
<Greeting />
</div>
)
}
The DOM React builds:
<div>
<p>Welcome!</p>
<p>Welcome!</p>
<p>Welcome!</p>
</div>
function Greeting()makes a component calledGreeting. Its name starts with a capital letter, and this function returns JSX.<Greeting />uses that component, like an HTML tag. When there is nothing between the opening and closing tag, you write one self-closing tag: a/before the>.- For every
<Greeting />, React calls theGreetingfunction once. There are three tags, so the function is called three times, and the result is three paragraphs. - The name
Greetingnever appears in the DOM. Only the JSX thatGreetingreturns reaches the page, here a<p>.
A component can also be written as an arrow function: const Greeting = () => <p>Welcome!</p>. The result is the same.
Why the capital letter matters
In the JSX lesson you saw that every tag is turned into React.createElement(...). The first letter of the tag's name decides what gets passed to React.createElement:
| JSX | Becomes | Meaning |
|---|---|---|
<Greeting /> |
React.createElement(Greeting) |
call the Greeting function |
<greeting /> |
React.createElement("greeting") |
make an HTML element called greeting |
A lowercase name is taken as an HTML tag name, so what gets passed is the text "greeting". Your function is never called. React makes an empty <greeting></greeting> element, so nothing shows. The console prints the warning The tag <greeting> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
So component names are always PascalCase: a capital letter at the start of every word, such as Greeting, ProductCard and UserAvatar.
Building a page from several components
In this code, App uses Greeting from the first section and two new components, Header and Footer:
function Header() {
return (
<header>
<h1>Hyper Sheets</h1>
</header>
)
}
function Footer() {
return (
<footer>
<p>© 2026</p>
</footer>
)
}
function App() {
return (
<div>
<Header />
<Greeting />
<Footer />
</div>
)
}
- A component that uses other components is called the parent, here
App. Each component it uses is called a child, soHeader,GreetingandFooterare its children. - Each component is written as its own function, outside every other component, not inside it. Want to change the footer? Change
Footeronly, and every page that uses it changes with it. - You can type the
©symbol directly, or write©inside JSX. Both give© 2026.
When should a part become a component? When it's used in more than one place (a button, a product card, a navbar), or when one component has become too long to read. Short text that appears only once can stay inside App.
⚠️ The component is there, so why does nothing show?
- A lowercase name.
<greeting />shows nothing. UseGreeting. returnalone on its line. If the JSX starts on the line underreturn, JavaScript inserts a semicolon right afterreturn. Soreturnends there, the component returnsundefined, and nothing shows. Put the opening bracket on the same line:return (.- Making a component but never using it. Writing
function Greetingshows nothing yet. A component only appears once<Greeting />is written inside a component that is shown. In the exercise, that component isApp. - Writing a component inside another one.
function App() { function Greeting() {...} }makesGreetinga new function every time React runsApp. React treats that new function as a different component, so React throws away its content and builds it again. Write every component outside the others.
TL;DR: A component is a function whose name starts with a capital letter and that returns JSX, such as function Greeting() { return <p>Welcome!</p> }. Use it by writing <Greeting /> inside another component. Each tag means one call of the Greeting function, and the component's name never reaches the DOM. A lowercase name (<greeting />) is taken as an HTML tag, so your function is never called and nothing shows. A page is built from components written separately: App uses Header, Greeting and Footer, so App is called the parent and those three are its children. Write return ( with the opening bracket on the same line as return, so the component doesn't return undefined.
⚡ Make it once, use it many times
Write:
function Greeting() {
return <p>Welcome!</p>
}
function App() {
return (
<div>
<Greeting />
<Greeting />
<Greeting />
</div>
)
}
Guess first: how many <p> elements are on the page? Does the name Greeting reach the DOM?
Three <p> elements, because every <Greeting /> means one call of the Greeting function. The name Greeting never appears in the DOM, only the JSX it returns.
Meaning: A component is a function whose name starts with a capital letter and that returns JSX. <Greeting /> uses that component like an HTML tag.
⚡ The capital letter is required
Guess first: written as <greeting />, what shows?
Nothing. A lowercase name is taken as an HTML tag, so your function is never called.
Meaning: Component names are always PascalCase: a capital letter at the start of every word, such as Greeting and ProductCard.
⚡ Build a page from components
Write:
function App() {
return (
<div>
<Header />
<Greeting />
<Footer />
</div>
)
}
Meaning: Header and Footer are other components, written like Greeting. App uses all three, so App is called the parent, and Header, Greeting and Footer are its children. Each component is written as its own function, outside every other component.
⚡ The opening bracket on the same line
Meaning: Write return ( with the opening bracket on the same line as return. If the JSX starts on the line under return, JavaScript inserts a semicolon right after return. So the component returns undefined, and nothing shows.