Need Assistance?

support@tutorialshub.in

JSX and Components

Creating and Reusing Components

React.js Free Lesson
5 min read
ADVERTISEMENT

What is a Component?

A component is a reusable piece of UI. A component can contain JSX, JavaScript logic, event handlers, and other components.

Most React components are functions whose names start with an uppercase letter.

Why Use Components?

  • Reduce duplicated code.
  • Make large pages easier to understand.
  • Reuse the same UI in different places.
  • Keep responsibilities separated.

Component Naming

Use PascalCase for component names such as ProductCard, UserProfile, and ShoppingCart. Lowercase names are interpreted as HTML elements.

Good Component Design

A component should have a clear responsibility. Avoid creating one huge component containing the entire application.

ADVERTISEMENT