Mohit Decodes
172 subscribers
68 photos
1 video
1 file
203 links
✨ Source Code for All Projects – Download & practice easily
πŸŽ“ Free Tutorials & Notes
πŸ› οΈ Coding Projects & Mini Apps
πŸ“Œ Subscribe on YouTube: Mohit Decodes πŸ””
πŸ“© For business inquiries: @MohitChoudhary0007
Download Telegram
Now, let's move to the next topic in Web Development Roadmap:

*βš›οΈ React Basics (Components, Props, State)*

Now you move from simple websites β†’ modern frontend apps.

React is used in real companies like Netflix, Facebook, Airbnb.

*βš›οΈ What is React*
React is a JavaScript library for building UI.
πŸ‘‰ Developed by Facebook
πŸ‘‰ Used to build fast interactive apps
πŸ‘‰ Component-based architecture
Simple meaning
- Break UI into small reusable pieces
Example
- Navbar β†’ component
- Card β†’ component
- Button β†’ component

*🧱 Why React is Used*
Without React
- DOM updates become complex
- Code becomes messy
React solves:
βœ… Faster UI updates (Virtual DOM)
βœ… Reusable components
βœ… Clean structure
βœ… Easy state management

*🧩 Core Concept 1: Components*
❓ What is a component
A component is a reusable UI block.
Think like LEGO blocks.

*✍️ Simple React Component*
function Welcome() {
return <h1>Hello User</h1>;
}
Use component
<Welcome />

*πŸ“¦ Types of Components*
πŸ”Ή Functional Components (Most Used)
function Header() {
return <h1>My Website</h1>;
}
πŸ”Ή Class Components (Old)
Less used today.

*βœ… Why components matter*
- Reusable code
- Easy maintenance
- Clean structure

*πŸ“€ Core Concept 2: Props (Passing Data)*
❓ What are props
Props = data passed to components.
Parent β†’ Child communication.

*Example*
function Welcome(props) {
return <h1>Hello {props.name}</h1>;
}
Use
<Welcome name="Deepak" />
Output πŸ‘‰ Hello Deepak

*🧠 Props Rules*
- Read-only
- Cannot modify inside component
- Used for customization

*πŸ”„ Core Concept 3: State (Dynamic Data)*
❓ What is state
State stores changing data inside component.
If state changes β†’ UI updates automatically.

*Example using useState*
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}

*🧠 How state works*
- count β†’ current value
- setCount() β†’ update value
- UI re-renders automatically
This is React’s biggest power.

*βš–οΈ Props vs State (Important Interview Question)*
Props State
Passed from parent Managed inside component
Read-only Can change
External data Internal data

*⚠️ Common Beginner Mistakes*
- Modifying props
- Forgetting import of useState
- Confusing props and state
- Not using components properly

*πŸ§ͺ Mini Practice Task*
- Create a component that shows your name
- Pass name using props
- Create counter using state
- Add button to increase count

*βœ… Mini Practice Task – Solution*

*🟦 1️⃣ Create a component that shows your name*
function MyName() {
return <h2>My name is Deepak</h2>;
}
export default MyName;
βœ” Simple reusable component
βœ” Displays static text

*πŸ“€ 2️⃣ Pass name using props*
function Welcome(props) {
return <h2>Hello {props.name}</h2>;
}
export default Welcome;
Use inside App.js
<Welcome name="Deepak" />
βœ” Parent sends data
βœ” Component displays dynamic value

*πŸ”„ 3️⃣ Create counter using state*
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return <h2>Count: {count}</h2>;
}
export default Counter;
βœ” State stores changing value
βœ” UI updates automatically

*βž• 4️⃣ Add button to increase count*
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<h2>Count: {count}</h2>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}
export default Counter;
βœ” Click β†’ state updates β†’ UI re-renders

🧩 *How to use everything in App.js*
import MyName from "./MyName";
import Welcome from "./Welcome";
import Counter from "./Counter";
function App() {
return (
<div>
<MyName />
<Welcome name="Deepak" />
<Counter />
</div>
);
}
export default App;


➑️ *Double Tap β™₯️ For More*
❀1
Backend Development Live Batch is Now Open!

If you’re serious about building real-world backend skills, this is for you.
I’m starting a job-oriented live training program on:

πŸ‘‰ Node.js | Express.js | MongoDB

πŸ’₯ Special Launch Offer: 90% OFF – Just β‚Ή4,999/-
πŸ“… Live classes: 3 days a week | 2 hours per session
🎯 Focus on practical projects, APIs, authentication & deployment
⏳ Offer valid for only 2 days

This program is for students & developers who want to move from tutorials to industry-ready backend skills.

πŸ“© mail at: mohitdecode@gmail.com
*πŸ”€ A–Z of Web Development* 🌐

*A – API*
Set of rules allowing different apps to communicate, like fetching data from servers.

*B – Bootstrap*
Popular CSS framework for responsive, mobile-first front-end development.

*C – CSS*
Styles web pages with layouts, colors, fonts, and animations for visual appeal.

*D – DOM*
Document Object Model; tree structure representing HTML for dynamic manipulation.

*E – ES6+*
Modern JavaScript features like arrows, promises, and async/await for cleaner code.

*F – Flexbox*
CSS layout module for one-dimensional designs, aligning items efficiently.

*G – GitHub*
Platform for version control and collaboration using Git repositories.

*H – HTML*
Markup language structuring content with tags for headings, links, and media.

*I – IDE*
Integrated Development Environment like VS Code for coding, debugging, tools.

*J – JavaScript*
Language adding interactivity, from form validation to full-stack apps.

*K – Kubernetes*
Orchestration tool managing containers for scalable web app deployment.

*L – Local Storage*
Browser API storing key-value data client-side, persisting across sessions.

*M – MongoDB*
NoSQL database for flexible, JSON-like document storage in MEAN stack.

*N – Node.js*
JavaScript runtime for server-side; powers back-end with npm ecosystem.

*O – OAuth*
Authorization protocol letting apps access user data without passwords.

*P – Progressive Web App*
Web apps behaving like natives: offline, push notifications, installable.

*Q – Query Selector*
JavaScript/DOM method targeting elements with CSS selectors for manipulation.

*R – React*
JavaScript library for building reusable UI components and single-page apps.

*S – SEO*
Search Engine Optimization improving site visibility via keywords, speed.

*T – TypeScript*
Superset of JS adding types for scalable, error-free large apps.

*U – UI/UX*
User Interface design and User Experience focusing on usability, accessibility.

*V – Vue.js*
Progressive JS framework for reactive, component-based UIs.

*W – Webpack*
Module bundler processing JS, assets into optimized static files.

*X – XSS*
Cross-Site Scripting vulnerability injecting malicious scripts into web pages.

*Y – YAML*
Human-readable format for configs like Docker Compose or GitHub Actions.

*Z – Zustand*
Lightweight state management for React apps, simpler than Redux.

*Double Tap β™₯️ For More*
❀1
React and JavaScript Developer Mock Interview | FRESHER | Real Interview Questions
https://youtu.be/pAitCb3BxdQ
❀1
Now, let's move to the next topic in Web Development Roadmap:

*βš›οΈ Simple CRUD UI in React*

Now you learn how real apps work.

πŸ‘‰ CRUD = Create, Read, Update, Delete

Every real application uses CRUD.

Examples
- Add task β†’ Create
- View tasks β†’ Read
- Edit task β†’ Update
- Delete task β†’ Delete


*πŸ”Ή What is CRUD in React*

CRUD means managing data using UI.

React handles CRUD using:
βœ… State
βœ… Events
βœ… Components

 

*🧠 Why CRUD is Important*
- Used in dashboards
- Used in admin panels
- Used in e-commerce apps
- Top interview question

If you know CRUD β†’ you can build real apps.
 

*🧩 Example Project: Todo List CRUD*
We will build:
βœ” Add item
βœ” Show item
βœ” Delete item
βœ” Update item

 

*✍️ Step 1: Setup State*
State stores list data.
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
return <div></div>;
}
export default App;
βœ” items β†’ list data
βœ” setItems() β†’ update list

 

*βž• Step 2: Create (Add Item)*
Add new item to list.
const [input, setInput] = useState("");
const addItem = () => {
setItems([...items, input]);
setInput("");
};
UI
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
 

*πŸ‘€ Step 3: Read (Show Items)*
Display list using map.
<ul>
{items.map((item, index) => (
<li key={index}>{item}</li>
))}
</ul>
 

*❌ Step 4: Delete Item*
Remove item from list.
const deleteItem = (index) => {
const newItems = items.filter((_, i) => i !== index);
setItems(newItems);
};
UI
<button onClick={() => deleteItem(index)}>Delete</button>
 

*✏️ Step 5: Update Item (Edit)*
Update existing data.
const updateItem = (index) => {
const newValue = prompt("Update item");
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
UI
<button onClick={() => updateItem(index)}>Edit</button>
 

*βœ… Complete CRUD UI Example*
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
const [input, setInput] = useState("");
const addItem = () => {
if (!input) return;
setItems([...items, input]);
setInput("");
};
const deleteItem = (index) => {
setItems(items.filter((_, i) => i !== index));
};
const updateItem = (index) => {
const newValue = prompt("Update item");
if (!newValue) return;
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
return (
<div>
<h2>Todo CRUD</h2>
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
<ul>
{items.map((item, index) => (
<li key={index}>
{item}
<button onClick={() => updateItem(index)}>Edit</button>
<button onClick={() => deleteItem(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
 

*🧠 How CRUD Works Internally*
- User action β†’ event triggers
- State updates
- React re-renders UI

This is React’s core workflow.

 

*⚠️ Common Beginner Mistakes*
- Mutating state directly
- Forgetting key in list
- Not copying arrays before update
- Confusing state updates

 

*πŸ§ͺ Mini Practice Task*
- Build a simple student list CRUD
- Add student name
- Edit student name
- Delete student
- Show total count


*βœ… Mini Practice Task – Solution βš›οΈ*

This covers:
βœ” Add student
βœ” Edit student
βœ” Delete student
βœ” Show total count

 

*🧩 Complete Working Example*
import { useState } from "react";
function App() {
const [students, setStudents] = useState([]);
const [input, setInput] = useState("");

// βž• Add Student
const addStudent = () => {
if (!input.trim()) return;
setStudents([...students, input]);
setInput("");
};

// ❌ Delete Student
const deleteStudent = (index) => {
const updated = students.filter((_, i) => i !== index);
setStudents(updated);
};

// ✏️ Edit Student
const editStudent = (index) => {
const newName = prompt("Enter new name");
if (!newName || !newName.trim()) return;
const updated = [...students];
updated[index] = newName;
setStudents(updated);
};

return (
<div style={{ padding: "40px", fontFamily: "Arial" }}>
<h2>Student CRUD</h2>
{/* Input Section */}
<input
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Enter student name"
/>
<button onClick={addStudent}>Add</button>
{/* Total Count */}
<p>Total Students: {students.length}</p>
{/* Student List */}
<ul>
{students.map((student, index) => (
<li key={index}>
{student}
<button onClick={() => editStudent(index)}>Edit</button>
<button onClick={() => deleteStudent(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
 

*🧠 What You Learned*
βœ… Managing list using state
βœ… Adding data using spread operator
βœ… Updating array safely
βœ… Filtering data to delete
βœ… Rendering list with .map()
βœ… Showing dynamic count

 

*⚠️ Interview Insight*
If interviewer asks:
πŸ‘‰ Why use [...students] before updating?

Answer: Because React state must not be mutated directly. We create a new copy to trigger re-render.

*Double Tap β™₯️ For More*
❀1
Now, let's move to the next topic in Web Development Roadmap:

*βš›οΈ React Hooks (useEffect & useRef)*

πŸ‘‰ Now you learn how React handles side effects and DOM access. These hooks are heavily used in real projects and interviews.

*🧠 What are React Hooks*
Hooks let you use React features inside functional components.

Before hooks β†’ class components required
After hooks β†’ functional components can do everything

βœ… *Common hooks*
- useState β†’ manage data
- useEffect β†’ handle side effects
- useRef β†’ access DOM or store values

*πŸ”„ Hook 1: useEffect (Side Effects)*

❓ *What is useEffect*

useEffect runs code when:
βœ… Component loads
βœ… State changes
βœ… Props change
βœ… Component updates

Simple meaning πŸ‘‰ Perform actions outside UI rendering.

πŸ“Œ *Why useEffect is needed*

Used for:
- API calls
- Fetch data from server
- Timer setup
- Event listeners
- Page load logic

*✍️ Basic Syntax*
import { useEffect } from "react";
useEffect(() => {
// code to run
}, []);

*πŸš€ Run only once (on page load)*

useEffect(() => {
console.log("Component mounted");
}, []);

πŸ‘‰ Empty dependency array β†’ runs once.

*πŸ”„ Run when state changes*

useEffect(() => {
console.log("Count changed");
}, [count]);

πŸ‘‰ Runs whenever count updates.


*⏱️ Real Example β€” Timer*

import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime(t => t + 1);
}, 1000);
return () => clearInterval(interval);
}, []);
return <h2>{time}</h2>;
}

βœ” Runs timer automatically
βœ” Cleans memory using return

*🎯 Hook 2: useRef (Access DOM / Store Values)*

❓ *What is useRef*

useRef gives direct access to DOM elements. Also stores values without re-rendering.

Simple meaning πŸ‘‰ Reference to element or value.

πŸ“Œ *Why useRef is used*

- Focus input automatically
- Access DOM elements
- Store previous value
- Avoid re-render

*✍️ Basic Syntax*
import { useRef } from "react";
const inputRef = useRef();

*🎯 Example β€” Focus input automatically*
import { useRef } from "react";
function InputFocus() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} />
<button onClick={handleFocus}>Focus</button>
</div>
);
}

βœ” Button click focuses input.

*βš–οΈ useState, useEffect, and useRef β€” What's the difference?*

- useState: Stores changing data that triggers re-renders.
- useEffect: Runs side effects (e.g., API calls, timers).
- useRef: Accesses DOM elements or stores values without re-rendering.

*⚠️ Common Beginner Mistakes*
- Forgetting dependency array in useEffect
- Infinite loops in useEffect
- Using useRef instead of state
- Not cleaning side effects

*πŸ§ͺ Mini Practice Task*
- Print message when component loads using useEffect
- Create timer using useEffect
- Focus input automatically using useRef
- Store previous value using useRef

*βœ… Mini Practice Task – Solution βš›οΈ*

*🟦 1️⃣ Print message when component loads (useEffect)*
import { useEffect } from "react";
function App() {
useEffect(() => {
console.log("Component loaded successfully");
}, []); // runs only once
return <h2>Check console</h2>;
}
export default App;
βœ… Runs once when page loads.

*⏱️ 2️⃣ Create timer using useEffect*
import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime((t) => t + 1);
}, 1000);
return () => clearInterval(interval); // cleanup
}, []);
return <h2>Time: {time}</h2>;
}
export default Timer;
βœ… Increases every second
βœ… Clears interval to prevent memory leak

*🎯 3️⃣ Focus input automatically using useRef*

import { useRef } from "react";
function FocusInput() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} placeholder="Enter text" />
<button onClick={handleFocus}>Focus Input</button>
</div>
);
}
export default FocusInput;
βœ… Click button β†’ input gets focus.


*πŸ”„ 4️⃣ Store previous value using useRef*

import { useState, useEffect, useRef } from "react";
function PreviousValue() {
const [count, setCount] = useState(0);
const prevCount = useRef();
useEffect(() => {
prevCount.current = count;
});
return (
<div>
<h2>Current: {count}</h2>
<h2>Previous: {prevCount.current}</h2>
<button onClick={() => setCount(count + 1)}> Increase </button>
</div>
);
}
export default PreviousValue;

βœ… Stores previous state without re-rendering.

*🧠 What You Learned*
βœ… Run code on component load
βœ… Handle side effects safely
βœ… Access DOM using useRef
βœ… Store values without re-render
βœ… Clean up side effects

➑️ *Double Tap β™₯️ For More*
❀1
πŸ‘1