Module 31: Introduction to React

Lesson 5 of 5 · 15–25 minutes

Project structure and your first screen

🏠The everyday picture

A well-organised toolbox: screwdrivers in one tray, spanners in another. You find things fast, and so does anyone who borrows it.

📘What it really is

src/
  components/    reusable pieces (buttons, cards)
  pages/         whole screens (Dashboard, EnquiryDetail)
  types.ts       shared TypeScript types
  data.ts        sample data, until there's a backend
  App.tsx
  main.tsx
export interface Enquiry {
  id: string;
  name: string;
  email: string;
  subject: string;
  status: "new" | "in-progress" | "closed";
  createdAt: string;
}

🖱️Try it

Set up the folders above. Add the Enquiry type and an array of five sample enquiries in data.ts. Create pages/Dashboard.tsx that shows the header, a heading "Open enquiries", and the cards. Style it with your Level 2 CSS, making sure it works on a phone. Look at the tree in React Developer Tools.

✅Quick check

What's the difference between components/ and pages/?

Show the answer

Components are reusable pieces; pages are whole screens built from them.

Where should the Enquiry type live, and why?

Show the answer

In a shared types.ts, so every component uses the same definition.

← PreviousComponents
ProLearners Assist