Facebook Pixel

How should I name React components?

Name components by what they are, not by where they live. UserProfile is clear; CardRight is not. Good names make a codebase readable and help you find components quickly.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in How to Create Your First React Components From Scratch

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.

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.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.