# Using Vite
npm create vite@latest my-react-app
cd my-react-app
npm install
npm run dev| Command | Description |
|---|---|
npm install |
Install all dependencies from package.json |
npm run dev |
Start development server (Vite) |
npm start |
Start development server (CRA) |
npm run build |
Build app for production |
npm run preview |
Preview production build (Vite) |
npm test |
Run tests (CRA has this by default) |
my-app/
βββ node_modules/ # All installed npm packages
βββ public/ # Static assets (like index.html, favicon, images)
β βββ index.html # Main HTML file (only one)
βββ src/ # All React code lives here
β βββ assets/ # Static files (images, fonts, etc.)
β βββ components/ # Reusable components (Navbar, Button, etc.)
β βββ pages/ # Different views or route pages (Home, About, etc.)
β βββ hooks/ # Custom React hooks (optional but clean)
β βββ context/ # Context API files (if using global state)
β βββ App.jsx # Root component
β βββ main.jsx # Entry point - connects React with DOM
β βββ index.css # Global CSS or Tailwind import
βββ .gitignore # Ignore files for Git
βββ package.json # Project metadata + dependencies
βββ tailwind.config.js # Tailwind config (if used)
βββ postcss.config.js # Tailwind PostCSS settings
βββ vite.config.js # Vite configuration file
βββ README.md # Project description| File/Folder | Purpose |
|---|---|
public/index.html |
Only HTML file, React mounts here via div#root. |
src/main.jsx |
Entry point. Renders <App /> inside #root. |
src/App.jsx |
Main component. Acts like the layout or router wrapper. |
src/components/ |
Contains reusable UI components (e.g., Button, Navbar). |
src/pages/ |
Contains full pages/views (e.g., Home, About). |
src/assets/ |
Images, logos, fonts, or static files. |
src/context/ |
Context API files for managing global state. |
src/hooks/ |
Custom reusable logic (e.g., useFetch, useAuth). |
| Extension | Use Case |
|---|---|
| Thunder Client | Lightweight REST client for testing APIs directly in VS Code. |
| TailwindCSS IntelliSense | Autocomplete, syntax highlighting, and linting for Tailwind CSS classes. |
| Postman | Advanced API testing and monitoring (external app, complements Thunder). |
| Auto Import | Automatically imports components, hooks, and functions as you type. |
| Auto Close Tag | Automatically closes HTML/JSX tags when you type an opening tag. |
| Auto Rename Tag | Automatically renames paired HTML/JSX tags when one is changed. |
| Reactjs Code Snippets | Shortcut snippets for fast writing of common React code blocks. |
| Path Intellisense | Autocompletes file paths when importing modules or assets. |
| npm Intellisense | Autocompletes npm packages in import statements. |
| ESLint | Identifies and fixes linting issues in JavaScript/TypeScript code. |
| VSCode React Refactor | Provides React-specific refactor tools like extracting components. |
| vscode-icons | Adds icons to files and folders for better visual navigation. |
| Day | Topic | Description | Example |
|---|---|---|---|
| 1 | What is React? | Introduction to React, its use cases, and SPA (Single Page Applications). | npx create-react-app my-app |
| 2 | Setting up React Project | Installing Node.js, creating a project using Vite or CRA, project structure. | npm create vite@latest |
| 3 | JSX Syntax | Writing JSX: HTML-like syntax in JS, expressions, fragments, etc. | <h1>Hello, {name}</h1> |
| 4 | Functional Components | Create and use functional components. | function Header() { return <h1 /> } |
| 5 | Props (Properties) | Passing data to components using props. | <User name="Mamun" /> |
| 6 | useState Hook | Adding state to functional components. | const [count, setCount] = useState(0) |
| 7 | Mini Project + Recap | Counter App using useState and props. | A working click counter with buttons |
Concept What Youβll Learn
- JSX Write HTML in JavaScript
- Functional Components Build simple, reusable pieces of UI
- Props Pass data to components
- State with useState() Make components dynamic
- Events Handle user actions like click, input change
JSX lets you write HTML inside JavaScript:
function App() {
const name = "Mamun";
return (
<div>
<h1>Hello, {name}!</h1>
<p>This is your first JSX.</p>
</div>
);
}
export default App;β Rules of JSX:
- Must return one parent element
- Use className instead of class
- JavaScript expressions are written inside {}
A component is a function that returns JSX.
function Header() {
return <h2>This is Header</h2>;
}
function App() {
return (
<div>
<Header />
<p>Welcome to the app!</p>
</div>
);
}β Split your UI into small, reusable components.
function Greeting(props) {
return <h2>Hello, {props.name}!</h2>;
}
function App() {
return (
<div>
<Greeting name="Mamun" />
<Greeting name="Sadia" />
</div>
);
}β Props are read-only. You can pass strings, numbers, arrays, even functions.
State allows a component to remember values.
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
export default Counter;β useState() returns:
count β current value
setCount() β function to update it
React uses onClick, onChange, etc.
function ButtonClicker() {
function handleClick() {
alert("Button clicked!");
}
return <button onClick={handleClick}>Click Me</button>;
}Input example:
function InputDemo() {
const [text, setText] = useState("");
return (
<input
type="text"
value={text}
onChange={(e) => setText(e.target.value)}
/>
);
}β Build a small app:
// App.jsx
import Greeting from "./Greeting";
import Counter from "./Counter";
function App() {
return (
<div>
<Greeting name="Mamun" />
<Counter />
</div>
);
}Create Greeting.jsx and Counter.jsx as explained earlier.
β Quiz: What is JSX? What is the purpose of useState()? Can props be changed inside a component? How do you handle a button click in React?
π οΈ Bonus: Folder Structure So Far
/src
βββ App.jsx
βββ Greeting.jsx
βββ Counter.jsx
βββ index.cssπ Next: If you're ready, I can now move to Week 2: useEffect(), Lists, Forms, and controlled components. Want to continue?
β Week 2 Summary: Dynamic Behavior with Hooks & Forms Day Focus Topics Covered 1 useEffect() Hook Side effects, API calls, lifecycle behavior 2 Lists & Keys Loop through data using map(), handle keys 3 Conditional Rendering Show/hide content based on conditions 4 Forms in React Controlled inputs using useState() 5 Form Submission Handle submit events, basic validation 6 Mini Project Day Build a "To-Do App" or "Contact Form" 7 Recap + Quiz Review concepts and test your understanding
π DAY 1: useEffect() β React's Lifecycle Hook Used for side effects, like:
Fetching data from an API
Setting document title
Setting timers
jsx Copy Edit import { useState, useEffect } from "react";
function EffectDemo() { const [count, setCount] = useState(0);
useEffect(() => {
document.title = Clicked ${count} times;
}, [count]);
return (
You clicked {count} times.
<button onClick={() => setCount(count + 1)}>Clickπ DAY 2: Rendering Lists & Keys jsx Copy Edit function ListDemo() { const items = ["Apple", "Banana", "Mango"]; return (
-
{items.map((item, index) => (
- {item} ))}
π DAY 3: Conditional Rendering jsx Copy Edit function UserGreeting({ isLoggedIn }) { return (
Welcome back!
:Please log in.
}π DAY 4: Controlled Forms Controlled = Form values are stored in useState().
jsx Copy Edit function ControlledInput() { const [name, setName] = useState("");
return (
<input type="text" value={name} onChange={(e) => setName(e.target.value)} />Your name is: {name}
); } β Input field is always in sync with the state.π DAY 5: Form Submission with Validation jsx Copy Edit function ContactForm() { const [email, setEmail] = useState("");
const handleSubmit = (e) => { e.preventDefault(); if (!email.includes("@")) { alert("Invalid email!"); return; } alert("Submitted: " + email); };
return (
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} /> Submit ); } π DAY 6: Mini Project β To-Do App π§ To-Do App Overview: Input field to add a taskDisplay task list
Option to delete tasks
jsx Copy Edit function TodoApp() { const [task, setTask] = useState(""); const [tasks, setTasks] = useState([]);
const addTask = (e) => { e.preventDefault(); if (!task.trim()) return; setTasks([...tasks, task]); setTask(""); };
const deleteTask = (index) => { setTasks(tasks.filter((_, i) => i !== index)); };
return (
-
{tasks.map((t, i) => (
- {t} <button onClick={() => deleteTask(i)}>β ))}
Mapping and keys
Controlled vs uncontrolled components
Form submit and validation
β Quiz: What is the purpose of useEffect()?
Why do we need a unique key in lists?
What's a controlled component?
How do you prevent page reload on form submit?
What's the difference between == and === in React (JS)?
β Folder Structure So Far bash Copy Edit /src βββ App.jsx βββ components β βββ Counter.jsx β βββ Greeting.jsx β βββ TodoApp.jsx β βββ ContactForm.jsx π Ready for Week 3? Topics for Week 3:
React Router DOM
Project pages
Navigation
URL parameters
Reusable components
Would you like me to start Week 3 now?
You said: now week 3
ChatGPT said: Perfect, AN Mamun! Welcome to Week 3 β this week is all about building multi-page applications with React Router DOM, learning how to navigate, and using URL parameters. You'll learn how to build a real-world app with routing!
β Week 3 Summary: React Router & Navigation Day Topic Description 1 Intro to React Router DOM Install and configure basic routing 2 Routes and Navigation Define routes, build navigation with or 3 Dynamic Routes with Params Use route parameters like /user/:id 4 useParams and useNavigate Access URL params and programmatically navigate 5 Nested Routes Render child components in parent routes 6 Mini Project Day Create a Blog or Product Detail site with routing 7 Review + Quiz Recap and test your understanding
π DAY 1: Install & Setup React Router 1οΈβ£ Install: bash Copy Edit npm install react-router-dom 2οΈβ£ Setup BrowserRouter: jsx Copy Edit // main.jsx or index.js import { BrowserRouter } from "react-router-dom"; import App from "./App";
ReactDOM.createRoot(document.getElementById("root")).render( ); π DAY 2: Define Routes & Navigation jsx Copy Edit // App.jsx import { Routes, Route, Link } from "react-router-dom"; import Home from "./pages/Home"; import About from "./pages/About";
function App() { return (
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</div>
); } β Create files:
jsx Copy Edit // pages/Home.jsx export default function Home() { return
; }// pages/About.jsx export default function About() { return
; } π DAY 3: Dynamic Routing with Params jsx Copy Edit // App.jsx <Route path="/user/:username" element={} /> jsx Copy Edit // pages/User.jsx import { useParams } from "react-router-dom";function User() { const { username } = useParams(); return
; } π§ Example URL:bash Copy Edit http://localhost:5173/user/mamun β shows: Hello, mamun! π DAY 4: useNavigate & useParams jsx Copy Edit // Navigate after login import { useNavigate } from "react-router-dom";
function Login() { const navigate = useNavigate(); const handleLogin = () => { // login logic here... navigate("/dashboard"); }; return Login; } β useParams() β get URL values β useNavigate() β redirect programmatically
π DAY 5: Nested Routes (Inside Layouts) jsx Copy Edit <Route path="/dashboard" element={}> <Route path="profile" element={} /> <Route path="settings" element={} /> In Dashboard.jsx:
jsx Copy Edit import { Outlet } from "react-router-dom";
export default function Dashboard() { return (
); } URL:/dashboard/profile β shows profile
/dashboard/settings β shows settings
π DAY 6: Mini Project β Blog App Features: Home Page β List of blog posts
Post Page β Dynamic route to view post by ID
About Page
Add useParams, useNavigate
π DAY 7: Review + Quiz π Review Topics: Install & setup React Router DOM
Use of Route, Link, useParams, useNavigate
Dynamic routes & nested routes
β Quiz: How do you define a dynamic route in React?
Difference between and ?
What does useParams() return?
How to programmatically redirect in React?
Whatβs the use of ?
π Suggested Folder Structure bash Copy Edit /src βββ App.jsx βββ main.jsx βββ /pages β βββ Home.jsx β βββ About.jsx β βββ User.jsx β βββ Dashboard.jsx β βββ Profile.jsx β βββ Settings.jsx β Done with Week 3! React Router unlocks the power of real app structure. Ready for Week 4?
Topics next week:
Props Drilling & Lifting State Up
Component Reusability
React Context API (avoid prop drilling)
Custom Hooks
Would you like to begin Week 4 now?
β Week 4 Summary: Data Flow, Props, and Context API Day Topic Description 1 Props Drilling Passing data through multiple levels of components 2 Lifting State Up Moving state to a common ancestor to share across components 3 Component Reusability Building flexible, reusable components with props 4 Intro to Context API Create and use global state with React.createContext() 5 useContext Hook Access context without manually passing props 6 Mini Project Day Theme toggler or simple user profile manager using Context API 7 Review + Quiz Recap weekβs learning and test your understanding
π DAY 1: Props Drilling Props drilling is when you pass data through many nested components unnecessarily.
jsx Copy Edit function App() { return ; }
function Parent({ user }) { return ; }
function Child({ user }) { return ; }
function GrandChild({ user }) { return
; } π΄ Problem: Passing user through every level β Solution: React Context APIπ DAY 2: Lifting State Up Shared state should live in the nearest common parent.
jsx Copy Edit function App() { const [count, setCount] = useState(0); return ( <> </> ); }
function CounterDisplay({ count }) { return
; }function CounterButton({ setCount }) { return <button onClick={() => setCount(c => c + 1)}>Increase; } πΌ State is lifted to so both components can access it.
π DAY 3: Component Reusability Make components flexible by using props:
jsx Copy Edit function Button({ text, onClick, color }) { return ( <button onClick={onClick} style={{ backgroundColor: color }}> {text} ); }
// Usage π DAY 4: Intro to Context API Avoid prop drilling by using Context:
jsx Copy Edit import { createContext, useState } from "react";
export const UserContext = createContext();
export function UserProvider({ children }) { const [user, setUser] = useState("Mamun");
return ( <UserContext.Provider value={{ user, setUser }}> {children} </UserContext.Provider> ); } Wrap your app:
jsx Copy Edit // main.jsx <React.StrictMode> </React.StrictMode> π DAY 5: useContext Hook Access context values easily:
jsx Copy Edit import { useContext } from "react"; import { UserContext } from "../context/UserContext";
function Profile() { const { user, setUser } = useContext(UserContext);
return (
π DAY 6: Mini Project β Theme Toggler Build a simple theme switcher:
Create ThemeContext.js
Provide dark/light mode
Toggle with button
Apply styles conditionally
jsx Copy Edit // ThemeContext.js export const ThemeContext = createContext();
export function ThemeProvider({ children }) { const [darkMode, setDarkMode] = useState(false);
return ( <ThemeContext.Provider value={{ darkMode, setDarkMode }}> {children} </ThemeContext.Provider> ); } Use it:
jsx Copy Edit const { darkMode, setDarkMode } = useContext(ThemeContext);
<button onClick={() => setDarkMode(!darkMode)}> Toggle Theme π DAY 7: Review + Quiz β Key Concepts Props drilling vs Context
Lifting state
Reusable components
Using useContext instead of passing props
β Quiz What is props drilling?
Why and when to use lifting state up?
How does createContext() work?
What is useContext() used for?
How do you make a reusable component?
Suggested File Structure (Context Example) bash Copy Edit /src βββ App.jsx βββ main.jsx βββ /components β βββ Profile.jsx β βββ ThemeToggle.jsx βββ /context β βββ UserContext.js β βββ ThemeContext.js π Week 4 Completed! You're now handling:
Reusability
State sharing
Global state via context
π Ready for Week 5?
Week 5:
Forms in React
Controlled vs Uncontrolled Components
Form Validation
React Hook Form
Would you like to start Week 5 now?
"# react.jsx"