A component is the smallest reusable unit of a React application: a function that receives props and returns JSX. Once you split an interface into components, each part can be developed, tested and reused on its own, and a complete page is assembled from those pieces like building blocks. Because every component is a plain function, there is no class syntax to learn before you start.
Group
Core Concepts
Kind
Pattern
Since
Earliest React versions
ℹ️ Info The editor transpiles JSX to JavaScript and renders the real UI in a sandbox; components mount automatically — no manual render call needed.
📝 Syntax
function Welcome({ name }) { // A component = a function returning JSX; the name must be capitalized
return <h1>Hello, {name}</h1>
}
<Welcome name="Alice" /> // Used just like an HTML tag
⚙️ Parameters
props
The data object passed in by the parent; components usually destructure it directly and must treat it as read-only.
Returns:A component function returns a piece of JSX (or null) describing what that component should render.
▶ Example
The example runs out of the box: it auto-renders when expanded, and edits take effect instantly.
Output:
Under the heading "Component reuse demo" three greetings appear — Hello, Alice!, Hello, Bob! and Hello, React Learner! — the same component rendered three times with different props.
⚠️ Warning Component names must start with a capital letter: a lowercase tag is treated by React as a plain HTML element.
💡 Tip Do not define a component inside another component — every render creates a new component type and rebuilds the whole subtree, so move it out to the outer scope.
ℹ️ Info Modern React only uses function components; class components survive in older code and the two styles can coexist.
Q Why must React component names start with a capital letter?
A The JSX compiler decides by the first letter: <div> compiles to a string tag while <Welcome> compiles to a component reference, so a lowercase name is treated as a native HTML element.
Q Can one file hold several components?
A Yes — keeping a few small, related components in one file is common. The convention is one main component per file, with small helpers kept alongside it.
Q What is the difference between function and class components?
A Class components use class syntax and lifecycle methods, while function components use Hooks for state and effects. Function components are the recommended choice for new projects.
Web-Tutorial Tech Team
A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.