Component
In one line
A component is a reusable, self-contained piece of UI written as a JavaScript function that returns JSX.
In simple words
A component is the fundamental building block of a React application. Think of it as a custom HTML element you define yourself — it encapsulates some markup, some styling, and some behavior, and you can reuse it anywhere.
A function component is simply a JavaScript function that receives a props object and returns JSX describing what should appear on screen. React calls your function whenever the props or state change, and updates the DOM to match the returned JSX.
Components let you break a complex UI into small, understandable pieces. A page might be composed of a <Header />, a <Sidebar />, a <ArticleList />, and a <Footer />. Each is independent, testable, and reusable.
Example
function Greeting({ name }) {
return <h1>Hello, {name}!</h1>;
}
// Reuse the component with different data
<Greeting name="Alice" />
<Greeting name="Bob" />Greeting is a function component. It receives name via props and returns JSX. You can render it many times with different data.
Common confusions
Confused with: element
The difference: A component is the function/class definition (the blueprint). An element is a plain object describing what to render — created by invoking a component like
<Greeting />orReact.createElement(Greeting).
Related terms
Related Resources
Related Lessons
- Components
Learn how to create and compose React components.
Related Projects
- Counter App
Build a counter to practice components and state.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.