DEV Community

Pushpak Paunikar
Pushpak Paunikar

Posted on

1 1

How React Differentiates Components From Regular HTML Tags

React Components names first letter should be capital or they won't work.

React Components are typically capitalized (e.g., MyComponent).
This capital letter signals React that it should treat the element as a Component, not as a regular HTML element.
React Component's name must start with capital letter to distinguish it from HTML element.

Regular HTML tags are written in lowercase letter.
React knows that if element's name is in lowercase, it corresponds to the HTML element.

//component
// Notice that component's first letter is capital
export default function MyComponent() {
    return(
        <h1>This is My Component</h1>
    )
}
Enter fullscreen mode Exit fullscreen mode
import MyComponent from './MyComponent'

export default function App() {
    return(
        <div>
            <MyComponent />
        <div>
    ) 
}
Enter fullscreen mode Exit fullscreen mode
  • starts with capital letter M, so React knows that we want to use our component called MyComponent.

  • h1 is in lowercase, so React knows we refer to a HTML tag.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series πŸ“Ί

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series