7. What is a Component?

A React Component is a reusable piece of the User Interface. Think of it as a custom JavaScript function that returns HTML (via JSX).

Navbar (Nav links)
Card (Product display)
Footer (Links & Copyright)
Button (Custom styles)

Instead of one huge file, we break the UI into these smaller, manageable parts.

8. Component Tree

App (Main) | ------------------- | | | Header Content Footer | ----------- | | Card1 Card2

App is the parent. All other components are children that get "injected" into the main App to create the final page.

9. Component Rules

Rule 1: Capitalization

Names MUST start with a Capital Letter. <Header /> is a component; <header> is just HTML.

Rule 2: One Parent

Everything inside the return must be wrapped in a single parent element (like a <div>).

Rule 3: className

We use className="" because class is already a keyword in JavaScript.

10. Component Syntax

function Welcome() {
  return (
    <h1>Hello Point Pikker</h1>
  );
}

export default Welcome;
PartMeaning
function Welcome()Declaring the component
return (...)The JSX (UI) to display
export defaultAllows you to use it in other files

12. Multiple Components

Header.js
export default function Header() { return <h1>Header</h1>; }
App.js
import Header from "./Header";

function App() {
  return (
    <div>
      <Header />
      <p>Main Body Content</p>
    </div>
  );
}

14. React vs HTML

FeatureStandard HTMLReact Component
StructureStatic / RigidDynamic / Smart
ReusabilityCopy-Paste neededCall <Tag /> once
UpdatesRequires Page RefreshAutomatic UI Refresh

15. React vs Plain JavaScript

FeaturePlain JavaScriptReact
DOMManual ManipulationVirtual DOM (Fast)
Code ReuseDifficult / Script-basedEasy Component Model
ComplexityGrows quicklyRemains organized

16. Practice Tasks

Task 1: Personal Info (Name, Dept, College).
Task 2: Build Header, Content, Footer separately.
Task 3: Student Card (Name, Age, Course).
Task 4: Product List (Laptop, Mobile, Tablet).

Challenge: Try to create a "Simple Website" using a Navbar, Home, and Footer component combined in App.js!

17. Learning Flow

React Setup → Components (Current) → JSX

Coming Next: Props → State → Hooks

Great job! You are building blocks. 🧱