Component Names Must Start with Capital Letters
You'll learn: Why React requires component names to begin with a capital letter and what happens if you forget.
The Core Rule
In React, all component names must start with a capital letter. This isn't just a style preference—it's how React distinguishes your custom components from built-in HTML elements.
Why Capitalization Matters
When React sees JSX like <div>, it knows to render a native HTML <div> element. But when it sees <MyComponent>, the capital letter signals "this is a custom component I need to look up."
Think of it like a name tag system: lowercase tags wear "HTML" badges, uppercase tags wear "Custom Component" badges. React checks the badge before deciding what to render.
What Happens If You Use Lowercase?
If you write a component with a lowercase name, React treats it as an HTML tag:
function myComponent() {
return <p>Hello</p>;
}
// React looks for an HTML element called "mycomponent"
<myComponent /> // ❌ Won't work as expected
Instead, React would try to render an unknown HTML element <mycomponent>, which browsers will display as an empty custom element.
The Correct Pattern
function MyComponent() {
return <p>Hello</p>;
}
// Capital letter tells React: "This is MY component"
<MyComponent /> // ✅ Works perfectly
Valid Naming Examples
<UserProfile />✅<Button />✅<NavBar />✅<button />✅ (HTML element, lowercase is correct)<userProfile />❌ (React thinks it's an HTML tag)
Key Takeaway: Component names must start with a capital letter so React can tell them apart from HTML tags. Lowercase = HTML, Uppercase = Your Component.