0
0
Reactframework~5 mins

Component naming rules in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
Why should React component names start with a capital letter?
React treats components starting with a capital letter as custom components. Lowercase names are treated as HTML tags. This helps React distinguish between built-in HTML elements and your own components.
Click to reveal answer
beginner
What is the recommended naming style for React components?
Use PascalCase for React component names. This means each word starts with a capital letter, like MyButton or UserProfile. It improves readability and follows React conventions.
Click to reveal answer
intermediate
Can you use numbers or special characters in React component names?
React component names can include numbers but should not start with a number. Special characters like spaces or symbols are not allowed. Stick to letters and numbers for valid names.
Click to reveal answer
beginner
What happens if you name a React component with a lowercase first letter?
React will treat it as a built-in HTML element, not a component. This means your component won't render as expected and React will look for a matching HTML tag instead.
Click to reveal answer
beginner
Is it okay to name a React component with a single lowercase letter?
No. Single lowercase letters are treated as HTML tags. Always start component names with an uppercase letter to ensure React recognizes them as components.
Click to reveal answer
Which of these is a valid React component name?
Auser-profile
BuserProfile
C123Profile
DUserProfile
Why should React component names start with a capital letter?
ATo make them look pretty
BReact treats capitalized names as components, lowercase as HTML tags
CIt is required by JavaScript syntax
DTo avoid errors in CSS styling
Which naming style is recommended for React components?
APascalCase
Bsnake_case
CcamelCase
Dkebab-case
What will React do if a component name starts with a lowercase letter?
ARender it as a custom component
BThrow a syntax error
CTreat it as a built-in HTML element
DAutomatically capitalize it
Can React component names contain special characters like hyphens?
ANo, special characters are not allowed
BOnly underscores are allowed
CYes, always
DOnly if wrapped in quotes
Explain the rules for naming React components and why they matter.
Think about how React decides what is a component versus an HTML element.
You got /5 concepts.
    What problems might happen if you name a React component starting with a lowercase letter?
    Consider how React interprets lowercase names.
    You got /4 concepts.