R
Rishtaara
React: The Complete Guide
Lesson 5 of 28Article14 min

Function Components

A React component is a JavaScript function that returns JSX. Function components are the default style in modern React.

Function Components — the modern standard

A React component is a JavaScript function that returns JSX. Function components are the default style in modern React.

Name components with PascalCase — UserCard, not userCard. React treats lowercase tags as HTML and uppercase as components.

Real-life example: A component is a reusable recipe card. Write the recipe once, cook it many times with different ingredients (props).

Simple function components
function Header() {
  return <header><h1>Rishtaara</h1></header>;
}

function Footer() {
  return <footer><p>&copy; 2026 Rishtaara</p></footer>;
}

function App() {
  return (
    <>
      <Header />
      <main><p>Learn React today.</p></main>
      <Footer />
    </>
  );
}

Component composition

Build small components and nest them inside bigger ones. This keeps code readable and reusable — the core idea of React.

Real-life example: Composition is like building a sandwich — bread, filling, and sauce are separate items you stack into one meal (page).

One component per file is a common convention. Export it and import where needed.
Nested components
function CourseCard({ title, lessons }) {
  return (
    <article className="card">
      <h2>{title}</h2>
      <p>{lessons} lessons</p>
    </article>
  );
}

function CourseGrid() {
  return (
    <section>
      <CourseCard title="React Guide" lessons={28} />
      <CourseCard title="JavaScript" lessons={30} />
    </section>
  );
}