Why Do React Components Need to Start with Capital Letters?
Emmanuel Christopher I.
Program coordinator and frontend engineer at Doyenify
It is likely that you have noticed that component names in React always begin with a capital letter. However, why is that the case?
In JSX, React components are written in a way that gets transformed into plain JavaScript using the React.createElement API, courtesy of Babel. Here's where capitalization plays a key role:
Why Does This Matter?
If you don’t follow this convention, you could run into bugs or unexpected behavior. For example, naming a component <buttonComponent> instead of <ButtonComponent> might cause React to throw errors or render the component incorrectly. Always capitalize your component names to ensure React recognizes and processes them the way you intend!
Thanks for reading!