Question

What's the React convention for naming user-defined (vs built-in) components?

#react

Answer

The convention is to start user-defined component names with a capital letter. Ex.

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

ReactDOM.render(
  <Welcome name="Sara" />,
  document.getElementById('root')
);

In contrast, built-in components like <h1 /> start with lowercase.

[^1]: Main Concepts > 4. Components and Props > Rendering a Component
[^2]: Advanced Guides > JSX in Depth > User-Defined Components Must Be Capitalized

Learn

Author

xavi

Reviews
Last
next

Students 1