Module 31: Introduction to React

Lesson 4 of 5 · 15–25 minutes

Components

🏠The everyday picture

Rubber stamps. Design one "PAID" stamp once, then stamp it wherever it's needed. Change the stamp and every new impression changes too.

📘What it really is

function Header() {
  return (
    <header className="header">
      <h1>Enquiries</h1>
    </header>
  );
}
// src/components/Header.tsx
export function Header() { ... }

// src/App.tsx
import { Header } from "./components/Header";

🖱️Try it

Create src/components/ with Header.tsx, Footer.tsx and EnquiryCard.tsx (showing a fixed name, subject and date for now). In App.tsx, show the header, three enquiry cards and the footer.

✅Quick check

Why does <header /> show an HTML header but <Header /> your component?

Show the answer

React treats lower-case names as HTML tags and capitalised names as components.

What's a sign a component should be split?

Show the answer

It does several jobs, or is too long to understand at a glance.

← PreviousJSX
ProLearners Assist