Write a JavaScript function whose name starts with a capital letter, and have it return JSX. You can then use that function name as a custom tag inside other components.
How to Create Your First React Components From Scratch
How do I create a React component?
The answer
More FAQs in How to Create Your First React Components From Scratch
Because React uses capitalization to distinguish custom components from built-in HTML tags. A lowercase name is treated as a DOM tag like div, while a capitalized name is treated as a component.
Props let you pass data into a component so it can render differently based on that data. A greeting component that takes a name prop can greet anyone, instead of being hardcoded to one name.
Not directly. A component must return a single root. To return siblings without an extra wrapper element, use a React fragment, written as empty angle brackets.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.