Complete Notes
Complete Notes
26 December 2025
React Components
- Component comprises 3 elements
a) Design
b) Styles
c) Logic
- Design is defined using HTML.
- Styles are defined with CSS.
- Logic is defined with JSX or TSX.
- Technically component is a Javascript
a) Class
b) Function
- Classes are supported in React but not recommended in modern code.
- React 19x version always recommends to design component with function.
Component Rules:
- A component must be a Javascript.
- You can create using declaration or expression.
- Name must start with uppercase letter.
Syntax: Declaration
function Login()
{
}
Syntax: Expression
const Login = function() {
}
- Component function can't be void type.
- A component function must return a JSX element.
function Login()
{
return (
<div>
JSX element
</div>
)
}
- Component function can return only one fragment.
return(
<h1> Welcome </h1> => invalid
<p> React JS </p>
)
return(
<header> => valid
<h1> </h1>
<p> </p>
</header>
- Every JSX element must have end token.
<img> => invalid
<img> </img>
<img />
<input> => invalid
<input />
<input> </input>
<br />
- Every JSX element can use only properties not attributes.
<img class="attribute"> => invalid
[Link]("img").className;
<img className="some" />
Ex:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
<style>
nav {
display: flex;
justify-content: space-between;
font-family: Arial;
padding: 20px;
font-size: 20px;
border:1px solid gray;
background-color: black;
color:white;
}
nav span {
margin-right: 20px;
}
</style>
<script src="../node_modules/react/umd/[Link]"></script>
<script src="../node_modules/react-dom/umd/[Link]"></script>
<script src="../node_modules/@babel/standalone/[Link]"></script>
<script type="text/babel">
function Navbar(){
return(
<nav>
<div className="brand-title">Shopping.</div>
<div>
<span> Home </span>
<span> Shop </span>
<span> Pages </span>
<span> Offers </span>
<span> Contact </span>
</div>
<button>Signin </button>
</nav>
)
}
function NewUser(){
return(
<div>
<a href="#">New User? Register</a>
</div>
)
}
function Login(){
return(
<form>
<h3>User Login</h3>
<dl>
<dt> User Name </dt>
<dd> <input type="text" /> </dd>
<dt>Password</dt>
<dd><input type="password" /></dd>
<dt>Email</dt>
<dd><input type="email" /></dd>
</dl>
<button>Login </button>
<NewUser />
</form>
)
}
const root = [Link]([Link]("root"));
[Link](
<section>
<Navbar />
<Login/>
</section>
);
</script>
</head>
<body>
<noscript> Please enable JavaScript on your browser.</noscript>
<div id="root"></div>
</body>
</html>
27 December 2025
- Install libraries
- Components
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Netflix</title>
<!-- Custom Style -->
<style>
body {
background-image: url("[Link]");
background-size: cover;
}
.shade {
background-color: rgba(0,0,0,0.6);
height: 100vh;
}
main {
padding-top: 100px;
}
</style>
function NetflixHeader(){
return(
<header className="d-flex justify-content-between p-4 text-white">
<div className="fs-1 fw-bold text-danger">NETFLIX</div>
<div className="d-flex flex-row align-items-center">
<div className="input-group">
<span className="bi input-group-text bi-translate"></span>
<select className="form-select">
<option>Language</option>
</select>
</div>
<button className="btn mx-3 btn-danger">SignIn</button>
</div>
</header>
)
}
function NetflixMain(){
return(
<main className="text-center text-white">
<div className="fs-1 fw-bold">Unlimited movies, shows <br /> and more</div>
<div className="fs-5 mt-3">Starts at ■ 149. Cancel at any time.</div>
<div className="d-flex justify-content-center">
<NetflixRegister />
</div>
</main>
)
}
function NetflixRegister(){
return(
<form className="mt-4">
<div className="my-3">
Ready to watch? Enter your email to create or restart your membership.
</div>
<div className="d-flex align-items-center justify-content-center">
<div>
<div className="input-group input-group-lg">
<input type="email" placeholder="Your email address" className="form-control" />
<button className="btn mx-3 btn-danger"> Get Started <span className="bi bi-chevr
</div>
</div>
</div>
</form>
)
}
function NetflixIndex(){
return(
<div className="shade">
<NetflixHeader />
<NetflixMain />
</div>
)
}
</script>
</head>
<body>
<noscript>Please enable Javascript on your browser.</noscript>
<div id="root"></div>
</body>
</html>
React 19 App
29 December 2025
Experimental Rollout: No
Note: Project starts automatically after installing, you can terminate using
"Ctrl + C"
30 December 2025
default export.
var title = "Welcome";
export default title;
- Every module can have only one default export.
- You can import default export outside the import block.
import { title } from "[Link]"; // invalid if title is default
import title from "[Link]"; // valid for default members
- You can import default members with others, but make sure that default is
the first import.
import { others } , title from "[Link]"; // invalid
import title, { others } from "[Link]"; // valid
- If you want to import all members from a module then you have to use
aliasing method.
import * as aliasName from "[Link]";
[Link];
[Link];
[Link];
- You can import members from multiple modules.
- If different modules have same name members then it leads to ambiguity.
- You can handle ambiguity issues by aliasing.
import { title as homeTitle } from "[Link]";
import { title as loginTitle } from "[Link]";
Ex:
[Link]
[Link]
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module">
import { title as homeTitle } from "./[Link]";
import { title as loginTitle } from "./[Link]";
[Link]("h1").textContent = loginTitle();
</script>
</head>
<body>
<h1></h1>
</body>
</html>
src
|_ components
|_ login
| |_
[Link]
|
|_ [Link]
|
|_ [Link]
|
|_register
|_ [Link]
|_ [Link]
|_ [Link]
5. CSS file is imported into ".jsx"
6. CSS file can't use type selectors for styling. Type selector applies the
styles for all occurrences across components.
7. It is recommended to use Id or class selectors.
Ex:
1. Components/login/[Link]
import './[Link]';
export function Login(){
return(
<div className='login-container'>
<form className='form-container'>
<h3>User Login</h3>
<dl>
<dt>User Name</dt>
<dd><input type="text" /></dd>
<dt>Password</dt>
<dd><input type="password"/></dd>
</dl>
<button>Login</button>
</form>
</div>
)
}
2. Components/login/[Link]
.login-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
border: 2px solid gray;
padding: 10px;
border-radius: 20px;
box-shadow: 5px 2px 2px black;
}
3. Src/[Link]
createRoot([Link]('root')).render(
<StrictMode>
<Login />
</StrictMode>,
)
31 December 2025
3. You can use bootstrap classes and components from any location
in project.
Syntax: Classes
<div className="alert alert-warning">
<input className="form-control">
<button className="btn btn-warning">
Syntax: Dynamic Attributes
data-bs-target
data-bs-toggle
data-bs-dismiss
<button data-bs-dismiss="alert"> Close </button>
Ex: [Link]
import './[Link]';
export function Login(){
return(
<div className='login-container'>
<form className='form-container alert alert-dismissible alert-warning p-3 w-25'>
<h3 className='bi bi-person-circle'> User Login</h3>
<button data-bs-dismiss="alert" className='btn btn-close'></button>
<dl>
<dt>User Name</dt>
<dd><input type="text" className='form-control' /></dd>
<dt>Password</dt>
<dd><input type="password" className='form-control' /></dd>
</dl>
<button className='btn btn-warning w-100'>Login</button>
</form>
</div>
)
}
Note: To get ideas about page designs you can try "Google Stitch".
[Link]
- Go to Web category and give following prompts
- Create a shopping home page
- Navbar at top with brand name, search bar & social icons.
- Features products in cards with 4 x 4 at section area.
- Footer with contact and services.
One-Way-Binding
implicitly.
- It can bind the data with UI elements but will not allow to change.
-
Two-Way-Binding
requires explicit implementation.
"http"
as protocol. - Http is a "
State-less"
protocol.
- It can't remember data between requests.
- Hence is not recommended to store data using variables for a component.
var name = "John"; // not good for component
- Every component has a local state. It is created while creating component.
- You can use local state to store data for component.
- Local state of component can be accessed by using
"useState()"
hook.
- Hook is a predefined business logic. It is a service.
- Server follows
Single Ton
pattern.
useState()
- It is hook provided by react to access the local state of component.
- It returns a getter and setter.
- Getter is used to read and return value from state.
- Setter is used to assign a new value into state.
const [ getter, setter ] = useState(anyValue);
[ getter, setter ] => It is de-structure declaration.
FAQ's:
1. Can we configure state using var & let keywords ?
A. Yes. But not recommended.
2. Why you are using "const" for state?
A. State must be initialized and used, It should not allow declaration and
assignment.
If we configure state with var & let then they allow declaration & assignment, which is not good for state.
3. If you configure using "const" then how you can set a value?
[Const will not allow to assign]
A. We set value not by assignment, it is done by using initialization.
const [price, setPrice] = useState(40);
setPrice = 50; // invalid - assignment to const not allowed
setPrice(50); // valid
01 January 2026
- useState()
Event. You can't set values into state while creating component.
Syntax:
useEffect(()=>{
// actions on mount
},[dependencies])
Every component mounts on first request.
If you want component to mount again, then you have to define the
dependencies.
1. Number Type
- A number in Javascript can be any one of the following
signed integer -10
unsigned integer 10
float 3.4
double 23.33
decimal 235.8321
exponent 2e3
hexadecimal 0x9001
binary 0b1010
octa 0o456
big int 9838286462n
- Numbers are presented using following methods
a) toFixed()
b) toPrecision()
c) toLocaleString()
- Style : currency, decimal, percent, unit
- notation: compact, scientific
Syntax:
const [price] = useState(500000);
{ [Link](91en-in', { style: 91currency', currency:'INR' }) }
- Number parsing is also same as in JS.
a) parseInt()
b) parseFloat()
- Verifying number is same. It is done with "isNaN()".
[ returns true if value is not number ]
2. Boolean Type
- It is configured using "true" & "false" keywords.
- React can't display boolean keywords in UI. It can just use them.
- React can't use boolean as number 0 & 1. [0=false, 1=true]
- React JSX can't use statements.
- You have to handle operations using operators or functions.
Syntax:
const [stock] = useState(true);
<p>
{ (stock===true) ? "True" : "False" }
</p>
3. String Type
- React can use all JS string formats with
a) Single Quote
b) Double Quote
c) Backtick
- Backtick represents a string that allows binding expression.
- Javascript data binding expression is "${ }".
- Binding expression is allowed only in string with backticks.
${ } Javascript Data Binding
{ } React Data Binding
Syntax:
const [styleClass] = useState(91bg-danger text-white');
<p className={ `border border-2 p-2 border-warning ${styleCalss}` }>
<p className={ "border border-2 p-2 border-warning " + styleClass}>
- All string manipulations are same as in JS.
Methods / Properties
- length startsWith()
- charAt() endsWith()
- charCodeAt() includes()
- indexOf() match()
- lastIndexOf() toUpperCase()
- slice() toLowerCase() etc.
- split()
- trim()
Syntax:
const [name, setName] = useState();
setName(prompt("Enter Name")); // string | null
<p>
{
(name===null) ? "Name is required" : name
}
</p>
5. Symbol
- It is a new Javascript primitive type. - It is used to configure unique hidden fields in object.
Ex:
<script>
var id = Symbol();
var product = {
[id] : 1,
name : "TV",
price: 45000
}
for(var property in product){
[Link](property + "<br>");
}
[Link](product[id]);
</script>
02 January 2026
useEffect(()=>{
},[])
return(
<div className="container-fluid">
<header className="p-2 mt-2 align-items-center bg-light d-flex justify-content-between">
<div>
<span className="bi bi-justify"></span>
<span className="mx-2">Amazon</span>
</div>
<div>
<div className="input-group">
<input type="text" className="form-control" placeholder="search amazon" />
<button className="btn btn-warning bi bi-search"></button>
</div>
</div>
<nav>
{
[Link](item=> <span className="mx-3" key={item}>{item}</span>)
}
</nav>
</header>
<section className="mt-3">
<ul className="list-group w-25">
{
[Link](item => <li className="list-group-item list-group-item-danger" key={item}>{
}
</ul>
<ul className="list-unstyled ms-4">
{
[Link](item=><li key={item}> <input type="checkbox" /> <label>{item}</label> </li
}
</ul>
</section>
</div>
)
}
[Link]()
for..in
b) Deleting a Key
delete [Link]
c) Find a Key
useEffect(()=>{
},[])
return(
<div className="container-fluid">
<h4>Product Details</h4>
<dl className="ms-4">
<dt>Product Id</dt>
<dd>{[Link]}</dd>
<dt>Name</dt>
<dd>{[Link]}</dd>
<dt>Price</dt>
<dd>{[Link]('en-in', {style:'currency', currency:'INR'})}</dd>
<dt>Shipped To</dt>
<dd>
<ol>
{
[Link](city=> <li key={city}>{city}</li>)
}
</ol>
</dd>
<dt>Ratings</dt>
<dd>
{[Link]} <span className="bi bi-star-fill text-success"></span>
[{[Link]}]
</dd>
</dl>
</div>
)
}
},[])
return(
<div className="container-fluid">
<h3>Products Table</h3>
<table className="table table-hover">
<thead>
<tr>
<th>Name <span className="bi bi-sort-alpha-down"></span> </th>
<th>Price <span className="bi bi-sort-alpha-down"></span> </th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{
[Link](product=>
<tr key={[Link]}>
<td>{[Link]}</td>
<td>{[Link]}</td>
<td>
<button className="btn btn-warning bi bi-pen-fill"></button>
<button className="btn btn-danger bi bi-trash-fill mx-2"></button>
</td>
</tr>
)
}
</tbody>
</table>
</div>
)
}
03 January 2026
- Number
- String
- Boolean
- Null
- Undefined
- Symbol
- Array
- Object
Syntax:
[Link](key, value);
[Link](key)
[Link](key)
[Link](key)
[Link]
[Link]()
[Link]()
[Link]() etc..
Ex: [Link]
useEffect(()=>{
},[])
return(
<div className="container-fluid">
<h3>Departure : {[Link]()} {weekdays[[Link]()]}, {months[[Link](
</div>
)
}
Ex:
{ moment(departure).format(91dddd DD, MMMM YYYY') }
Ex: [Link]
import { useEffect, useState } from "react"
useEffect(()=>{
},[])
return(
<div className="container-fluid p-4">
<h2>Departure : {moment(departure).format('dddd DD, MMMM YYYY')} </h2>
</div>
)
}
Syntax:
Ex: [Link]
useEffect(()=>{
},[])
return(
<div className="container-fluid p-4">
<p>Your Password : {password}</p>
{
([Link](regEx)) ? "Strong Password": "Weak Password one uppercase letter required"
}
</div>
)
}
a) XMLHttpRequest Object
b) fetch() Promise
XMLHttpRequest
2. Configure request
3. Send request
[Link]();
4. Execute request
[Link] = function() {
}
1 Initial
2 Success
3 Complete
4 Ready
if([Link]===4)
{
// [Link] => convert into JSON using "[Link]()"
}
Ex:
public/[Link]
{
"title": "Apple iPhone 16 (Pink, 256 GB)",
"price": 79900,
"image": "[Link]",
"rating": {"rate":4.9, "ratings":160567, "reviews":5822},
"offers": [
"Bank Offer5% cashback on Axis Bank Flipkart Debit Card up to ■ 750T&C",
"Bank Offer5% cashback on Flipkart Axis Bank Credit Card upto ■ 4,000 per statement quarterT&C",
"Bank OfferFlat ■ 400 off on Flipkart Bajaj Finserv Insta EMI Card. Min Booking Amount: ■ 40,000T&C"
]
}
[Link]
function LoadData(){
var http = new XMLHttpRequest();
[Link]("get", "[Link]", true);
[Link]();
[Link] = function(){
if([Link]===4){
setProduct([Link]([Link]));
}
}
}
useEffect(()=>{
LoadData();
},[])
return(
<div className="container-fluid">
<div className="mt-4">
<div className="row">
<div className="col-3">
<img width="100%" src={[Link]} />
</div>
<div className="col-9">
<div className="fs-5">{[Link]}</div>
<div className="mt-2">
<span className="badge bg-success text-white rounded">{[Link]} <span cla
<span className="mx-2 text-secondary fw-bold"> {[Link]
</div>
<div className="mt-3 fs-2 fw-bold">
{[Link]('en-in',{style:'currency', currency:'INR', minimumFract
</div>
<div className="mt-3">
<h5>Available Offers</h5>
<ul className="list-unstyled">
{
[Link](offer=>
<li className="bi bi-tag-fill text-success my-4" key={offer}><span classN
)
}
</ul>
</div>
</div>
</div>
</div>
</div>
)
}
05 January 2026
1. XMLHttpRequest
Issues with XMLHttpRequest
- It synchronous by default.
- It is async by default.
Syntax:
fetch("url")
.then(function(response){
}
.catch(function(error){
}
.finally(function(){
})
- It is a DOM method.
Ex: [Link]
import { useEffect, useState } from "react"
return(
<div className="container-fluid">
<div className="mt-4">
<div className="row">
<div className="col-3">
<img width="100%" src={[Link]} />
</div>
<div className="col-9">
<div className="fs-5">{[Link]}</div>
<div className="mt-2">
<span className="badge bg-success text-white rounded">{[Link]} <span cla
<span className="mx-2 text-secondary fw-bold"> {[Link]
</div>
<div className="mt-3 fs-2 fw-bold">
{[Link]('en-in',{style:'currency', currency:'INR', minimumFract
</div>
<div className="mt-3">
<h5>Available Offers</h5>
<ul className="list-unstyled">
{
[Link](offer=>
<li className="bi bi-tag-fill text-success my-4" key={offer}><span classN
)
}
</ul>
</div>
</div>
</div>
</div>
</div>
)
}
- React can use various 3rd party libraries for handling AJAX requests.
a) axios
b) whatwg-fetch
- It uses XMLHttpRequest.
- It is async by default.
Syntax:
[Link]("url").
then(function(response){
[Link], status, statusCode etc.
})
.catch(function(error){
})
.finally(function(){
})
Ex: [Link]
function LoadData(){
[Link]('[Link]')
.then(response=>{
setProduct([Link]);
[Link]([Link]);
})
.catch(error=>{
[Link](error);
})
.finally(()=>{
[Link]('Request End');
})
}
useEffect(()=>{
LoadData();
},[])
return(
<div className="container-fluid">
<div className="mt-4">
<div className="row">
<div className="col-3">
<img width="100%" src={[Link]} />
</div>
<div className="col-9">
<div className="fs-5">{[Link]}</div>
<div className="mt-2">
<span className="badge bg-success text-white rounded">{[Link]} <span cla
<span className="mx-2 text-secondary fw-bold"> {[Link]
</div>
<div className="mt-3 fs-2 fw-bold">
{[Link]('en-in',{style:'currency', currency:'INR', minimumFract
</div>
<div className="mt-3">
<h5>Available Offers</h5>
<ul className="list-unstyled">
{
[Link](offer=>
<li className="bi bi-tag-fill text-success my-4" key={offer}><span classN
)
}
</ul>
</div>
</div>
</div>
</div>
</div>
)
}
Ex:
1. Public/[Link]
[
{
"title": "DHURANDHAR",
"poster": "[Link]",
"language": "Hindi",
"certificate": "A"
},
{
"title": "IKKIS",
"poster": "[Link]",
"language": "Hindi",
"certificate": "UA 13+"
},
{
"title": "THE SPONGEBOB MOVIE",
"poster": "[Link]",
"language": "English",
"certificate": "UA 7+"
},
{
"title": "THE HOUSEMAID",
"poster": "[Link]",
"language": "English",
"certificate": "A"
},
{
"title": "AVATAR : FIRE & ASH",
"poster": "[Link]",
"language": "English",
"certificate": "UA 15+"
}
2. Components/inox/[Link]
function LoadMovies(){
[Link]('[Link]')
.then(response=>{
setMovies([Link]);
})
}
useEffect(()=>{
LoadMovies();
},[])
return(
<div className="container-fluid p-3">
<header>
<div className="text-center fw-bold fs-4">Inox Movies</div>
</header>
<section className="mt-3 d-flex flex-row">
{
[Link](movie=>
<div key={[Link]} className="card m-2 p-2 w-25">
<img src={[Link]} className="card-img-top" height="200"/>
<div className="card-header text-center fw-bold">
{[Link]}
</div>
<div className="card-body">
<dl>
<dt>Language</dt>
<dd>{[Link]}</dd>
<dt>Certificate</dt>
<dd>{[Link]}</dd>
</dl>
</div>
<div className="card-footer">
<button className="btn btn-warning w-100"> Book Ticket </button>
</div>
</div>
)
}
</section>
</div>
)
}
06 January 2026
- XMLHttpRequest
- fetch()
- axios
Syntax: React
<div style={ { backgroundColor: 91red', color: 91white' } }>
Syntax: HTML
<div style="background-color:red; color:white">
Ex: [Link]
function LoadProducts(url){
[Link](url)
.then(response=>{
setProducts([Link]);
})
}
function LoadCategories(){
[Link](`[Link]
.then(response=>{
[Link]('all');
setCategories([Link]);
})
}
useEffect(()=>{
LoadProducts(`[Link]
LoadCategories();
},[])
return(
<div className="container-fluid">
<header className="d-flex align-items-center justify-content-between p-2 bg-light">
<div>
<span className="bi bi-bag fs-4 fw-bold text-dark"></span>
<span className="fs-4 mx-2 fw-bold">Shopping.</span>
</div>
<div>
<div className="input-group">
<input className="form-control" type="text" placeholder="Search [Link]" />
<button className="btn btn-warning bi bi-search"></button>
</div>
</div>
<div>
<button className="btn bi bi-person"></button>
<button className="btn mx-2 bi bi-heart"></button>
<button className="btn bi bi-cart4"></button>
</div>
</header>
<section className="row mt-2">
<nav className="col-2">
</ul>
</div>
</div>
</nav>
<main className="col-10 d-flex overflow-auto flex-wrap" style={{height:'500px'}}>
{
[Link](product=>
<div key={[Link]} className="card m-2 p-2" style={{width:'200px'}}>
<img src={[Link]} className="card-img-top" height="100" />
<div className="card-header" style={{height:'120px'}}>
{[Link]}
</div>
<div className="card-body">
<dl>
<dt>Price</dt>
<dd>{[Link]}</dd>
<dt>Rating</dt>
<dd>{[Link]} <span className="bi bi-star-fill text-succe
</dl>
</div>
<div className="card-footer">
<button className="btn w-100 btn-warning bi bi-cart4"> Add to Cart</butto
</div>
</div>
)
}
</main>
</section>
</div>
)
}
07 January 2026
1. What is Event?
9. Event Profiling
What is Event?
Syntax:
function DeleteClick() { } // subscriber
onclick="DeleteClick()" // sender
Subscriber : defines the actions to perform.
<button onclick="DeleteClick()">
on : handler
click : event
Syntax:
[Link]("button").addEventListener("click", function(){
})
Ex:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function bodyload(){
[Link]("btnDelete").addEventListener("click",()=>{
[Link]("Record Deleted");
})
var button = [Link]("button");
[Link] = "Insert";
[Link]("click",()=>{
[Link]("Inserted..");
})
[Link]("body").appendChild(button);
}
</script>
</head>
<body onload="bodyload()">
<button id="btnDelete">Delete</button>
</body>
</html>
b) event
Syntax:
<button onclick="Name(this, event)">
function Name(element, e)
{
[Link], name, value, etc.
[Link], clientY, shiftKey, etc.
}
Ex:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function Player(element, e){
[Link](`Button Name : ${[Link]}<br>Button Id : ${[Link]}<br>Clicked at X axis p
}
</script>
</head>
<body>
Syntax:
function Details(...params) { }
Ex:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function DetailsClick(element, ...product){
[Link](product);
[Link]([Link]);
}
</script>
</head>
<body>
<button id="btnDetails" onclick="DetailsClick(this, 1, 'TV', true, ['Delhi','Hyd'])">Details</button>
</body>
</html>
- Event listener can have only one argument, which refers to "event".
Syntax:
.addEventListener("click", function(e){
[Link], clientY, shiftKey => event details
[Link], name, value => element details
})
Ex:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function bodyload(){
[Link]("btnDelete").addEventListener("click",(e)=>{
[Link](`Button Id : ${[Link]}\nX Position : ${[Link]}`);
})
}
</script>
</head>
<body onload="bodyload()">
<button id="btnDelete" value="Delete">Delete</button>
</body>
</html>
- It is a mechanism where the child event may trigger the parent events.
Syntax:
function ChildEvent(e)
{
[Link]();
}
08 January 2026
- What is Event?
- Event Handler
- Event Listener
- Event Arguments
a) Default Args
b) Custom Args
- Event Propagation
stopPropagation()
- Prevent Default
preventDefault()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function ExecuteClick(){
setTimeout(()=>{
[Link]('Macro Task');
},0)
[Link]('Normal Task');
Synthetic Events"
library for virtual DOM events.
- SyntheticEvent is the base for all events in virtual DOM.
- SyntheticEvent maps to browser event.
Syntax:
onClick : MouseEvent : EventHandler : SyntheticEventHandler: BaseSynthenticEvent
- SyntheticEvents are defined in camel case.
- Events in react point towards a function in component.
Syntax:
<button onClick={ handleInsertClick } >
function handleInsertClick()
{
}
- Synthetic Event sends default arguments to function.
- The arguments refers to Event Listener.
- Event Listener uses a single argument to handle element & event details.
function handleInsertClick(e)
{
[Link], name, value etc.
[Link], clientY etc.
}
Ex:
[Link]
function handleInsertClick(e){
[Link](`Button Name : ${[Link]}\nButton Id:${[Link]}\nX Position: ${[Link]}`);
}
return(
<div className="container-fluid p-4">
<button onClick={handleInsertClick} name="Insert" id="btnInsert">Insert</button>
</div>
)
}
event
as
a formal parameter in event callback.
Syntax:
<button onClick= { (e) => handleInsertClick(e, your_args) }>
function handleInsertClick(e, ...params)
{
}
- Event Propagation & Preventing default events is same as in JS.
function handleEvent(e)
{
[Link]();
[Link]();
}
"onChange".
- You can enable two-way-binding only with "onChange".
- You can configure multiple events for any element in component, but
two-way binding can be enabled only with "onChange".
Syntax:
<input type="text" onChange={ handleChange } />
<select onChange={handleChange} />
<input type="checkbox" onChange={handleChange} />
function handleChange(e)
{
[Link]; // returns element value
}
Ex:
function handleNameChange(e){
setUserName([Link]);
}
return(
<div className="container-fluid p-4">
<dl>
<dt>User Name</dt>
<dd><input type="text" onChange={handleNameChange} value={userName} /></dd>
</dl>
<h2>Hello ! {userName}</h2>
</div>
)
}
09 January 2026
1. Mouse Events
onMouseOver : actions when mouse pointer is over element.
onMouseOut : when mouse pointer moves out of element.
onMouseDown : when user hold down mouse button on element
onMouseUp : when button is released on element.
onMouseMove : while moving mouse pointer
- The popular properties used with mouse events
a) clientX
b) clientY
Ex: MouseOver
1. public/[Link]
{
"image": "[Link]"
},
{
"image": "[Link]"
},
{
"image": "[Link]"
},
{
"image": "[Link]"
}
]
2. Components/mouse-demo/[Link]
.mobile-container {
.mobile-container:hover {
border:4px solid blue;
cursor: grab;
}
3. Components/mouse-demo/[Link]
function handleMouseOver(e){
setPreviewImage([Link]);
}
return(
<div className="container-fluid p-3">
<div className="row mt-4">
<div className="col-2">
{
[Link](mobile=>
<div key={[Link]} className="my-4 mobile-container" style={{width:'100px'}}
<img src={[Link]} onMouseOver={handleMouseOver} width="100%" height="10
</div>
)
}
</div>
<div className="col-10">
<img width="400" height="500" src={previewImage} />
</div>
</div>
</div>
)
}
@keyframes Spin {
from {
transform: rotate(0deg) scale(1);
}
to {
transform: rotate(360deg) scale(2);
}
}
[Link]
import './[Link]';
function handleMouseDown(){
setAnimationObject({animationName:'Spin', animationDuration:'500ms', animationIterationCount:'infinit
}
function handleMouseUp(){
setAnimationObject({animationName:'Spin', animationDuration:'3s', animationIterationCount:'infinite',
}
return(
<div className="d-flex justify-content-center align-items-center" style={{height:'100vh'}}>
<img onMouseDown={handleMouseDown} onMouseUp={handleMouseUp} src="[Link]" style={animationObj
</div>
)
}
function handleMouseMove(e){
setStyleObject({position:'fixed', top:`${[Link]}px`, left:`${[Link]}px`});
}
return(
<div onMouseMove={handleMouseMove}>
<div style={{height:'1000px'}}>
<p className="fs-2">Move mouse pointer to test</p>
</div>
<img src="[Link]" style={styleObj} width="50" height="50" />
</div>
)
}
2. Keyboard Events
onKeyUp
onKeyDown
onKeyPress [deprecated]
-
KeyPress
is good for handling character ASCII code. However it is
deprecated and character code can be accessed using "charCodeAt()"
function.
10 January 2026
1. Mouse Events
2. Keyboard Events
Ex:
[Link]
function LoadUsers(){
[Link]('[Link]')
.then(response=>{
setUsers([Link]);
})
}
useEffect(()=>{
LoadUsers();
},[])
function verifyUser(e){
for(var user of users)
{
if([Link]===[Link]){
setUserMsg('User Name Taken - Try Another');
setUserClass('text-danger');
break;
} else {
setUserMsg('User Name Available');
setUserClass('text-success');
}
}
}
function VerifyPassword(e){
if([Link](/(?=.*[A-Z])\w{4,15}/)) {
// strong
setProgressWidth({width:'100%'})
setStrengthColor('bg-success');
setPasswordMsg('Strong Password');
} else {
if([Link]<4){
// poor
setProgressWidth({width:'30%'})
setStrengthColor('bg-danger');
setPasswordMsg('Poor Password');
} else {
// weak
setProgressWidth({width:'70%'});
setStrengthColor('bg-warning');
setPasswordMsg('Weak Password');
}
}
}
return(
<div className="container-fluid p-4">
<h3>Register User</h3>
<dl className="w-25">
<dt>User Name</dt>
<dd><input type="text" className="form-control" onKeyUp={verifyUser} /></dd>
<dd className={userClass}>{userMsg}</dd>
<dt>Password</dt>
<dd>
<input onKeyUp={VerifyPassword} className="form-control" type="password" />
</dd>
<dd>
<div className="progress">
<div className={`progress-bar text-white progress-bar-striped progress-bar-animated ${s
{passwordMsg}
</div>
</div>
</dd>
</dl>
</div>
)
}
3. Button Events
onClick
onDoubleClick
onContextMenu
onSelectStart
- Button events can handle various interactions, but require actual DOM
events to manage browser actions.
[Link]
[Link]
[Link]
- You can disable any event by configuring a function that returns false.
function handle()
{
[Link] = function() {
return false;
}
}
Ex:
[Link]
function handleDoubleClick(){
[Link]('[Link]','iPhone','width=300 height=400');
}
function handleContextMenu(){
[Link] = ()=>{
alert('Right Click Not Allowed');
return false;
}
}
return(
<div onContextMenu={handleContextMenu} className="container-fluid p-4">
<h1>Highly Confidential</h1>
<p>Right click not allowed on this page</p>
<img onDoubleClick={handleDoubleClick} src="[Link]" width="50" height="50" />
<p>Double Click to View Large</p>
</div>
)
}
19 January 2026
- Mouse Events
- Keyboard Events
- Button Events
- Clipboard Events
onChange
defines actions to perform while changing the value in element.
-
onFocus
defines actions when element is in focus.
-
onBlur
defines actions when element looses the focus.
Ex:
[Link]
function handleNameBlur(){
setUserName([Link]());
setMsg('');
}
function handleNameChange(e){
setUserName([Link]);
}
function handleNameFocus(){
setMsg('Name in Block Letters');
}
return(
<div className="container-fluid">
<h2>Register</h2>
<dl className="ms-4">
<dt>User Name</dt>
<dd><input type="text" value={userName} onFocus={handleNameFocus} onChange={handleNameChange}
<dd className="text-warning fs-6">{msg}</dd>
</dl>
</div>
)
}
function CalculateEMI(){
var P = parseInt(loanAmount);
var R = parseFloat(rate)/12/100;
var N = parseInt(year) * 12;
var emi = P * R * ([Link](1+R,N)) / ([Link](1+R,N)) - 1;
setEMI(emi);
}
function handleAmountChange(e){
setLoanAmount([Link]);
CalculateEMI();
}
function handleYearChange(e){
setYears([Link]);
CalculateEMI();
}
function handleRateChange(e){
setRate([Link]);
CalculateEMI();
}
function handleCalculateClick(){
var P = parseInt(loanAmount);
var R = parseFloat(rate)/12/100;
var N = parseInt(year) * 12;
var emi = P * R * ([Link](1+R,N)) / ([Link](1+R,N)) - 1;
setEMI(emi);
}
return(
<div className="container-fluid" style={{height:'100vh'}}>
<div className="row mt-4">
<div className="col-6">
<div className="row">
<div className="d-flex justify-content-between">
<div><label className="form-label fw-bold">Loan Amount</label></div>
<div><input type="text" onChange={handleAmountChange} value={loanAmount} className="
</div>
<div>
<input type="range" onChange={handleAmountChange} min="25000" value={loanAmount} step
<div>
<span>₹ 25,000/-</span>
<span className="float-end">₹ 10,00,000/-</span>
</div>
</div>
</div>
<div className="row my-3">
<div className="d-flex justify-content-between">
<div><label className="form-label fw-bold">Loan Tenure</label></div>
<div><input onChange={handleYearChange} style={{width:'50px'}} value={year} type="t
</div>
<div>
<input type="range" onChange={handleYearChange} min="1" max="7" value={year} classNam
<div>
<span>1 Year</span>
<span className="float-end">7 Years</span>
</div>
</div>
</div>
<div className="row my-3">
<div className="d-flex justify-content-between">
<div><label className="form-label fw-bold">Loan Interest</label></div>
<div><input type="text" onChange={handleRateChange} value={rate} style={{width:'70p
</div>
<div>
<input type="range" onChange={handleRateChange} value={rate} min="10.45" step="0.01"
<div>
<span>10.45%</span>
<span className="float-end">18.45%</span>
</div>
</div>
</div>
<div className="text-center">
<button onClick={handleCalculateClick} className="btn btn-primary">Calculate</button>
</div>
</div>
<div className="col-6 ps-4">
<h3>Loan Installment Amount</h3>
<div className="h1">
{[Link]('en-in', {style:'currency', currency:'INR', minimumFractionDigits
</div>
</div>
</div>
</div>
)
}
Timer Events
20 January 2026
- setTimeout()
- clearTimeout()
- setInterval()
- clearInterval()
Debounce
Syntax:
setTimeout(function(){ }, interval);
clearTimeout(referenceName);
useRef() Hook:
tasks in memory.
Syntax:
let thread = useRef(null);
Ex:
[Link]
function Level1(){
setMsg('Volume Increased : 20%');
}
function Level2(){
setMsg('Volume Increased : 70%');
}
function Level3(){
setMsg('Volume Full');
}
function VolumeUpClick(){
setTimeout(Level1, 3000);
[Link] = setTimeout(Level2, 6000);
setTimeout(Level3, 10000);
}
function handleCancelClick(){
alert('Canceled');
clearTimeout([Link]);
}
return(
<div className="container-fluid p-4">
<button onClick={VolumeUpClick} className="btn btn-warning bi bi-volume-up"></button>
<button onClick={handleCancelClick} className="btn btn-danger mx-2">Cancel Level2</button>
<p className="fs-4">{msg}</p>
</div>
)
}
Throttle
- It loads a task into memory and releases a copy of task into process at
Syntax:
clearInterval(referenceName);
Ex:
[Link]
function LoadTime(){
setNow(new Date());
}
useEffect(()=>{
setInterval(LoadTime, 1000);
},[])
return(
<div className="container-fluid text-center">
<div className="h1">{[Link]()}</div>
</div>
)
}
Task: Create a Stop Watch using Throttle
21 January 2026
function handleStartClick(){
[Link] = setInterval(StartWatch,1);
}
function handleStopClick(){
clearInterval([Link]);
}
return(
<div className="container-fluid text-center p-4">
<div className="bg-primary p-4 text-white fw-bold fs-1 w-75 row">
<div className="col">
00
</div>
<div className="col">
:
</div>
<div className="col">
00
</div>
<div className="col">
:
</div>
<div className="col">
{seconds}
</div>
<div className="col">
:
</div>
<div className="col">
{milliSeconds}
</div>
<div className="mt-3 fs-5">
<button onClick={handleStartClick} className="btn btn-light">Start</button>
<button onClick={handleStopClick} className="btn btn-warning mx-2">Stop</button>
</div>
</div>
</div>
)
}
Ex: [Link]
function LoadProductManually(id)
{
[Link](`[Link]
.then(response=>{
setProduct([Link]);
})
}
function LoadProductAuto(){
[Link] = [Link] + 1;
LoadProductManually([Link]);
}
function handlePlayClick(){
[Link] = setInterval(LoadProductAuto, 5000);
setStatus('Slide Show - Started');
}
function handlePauseClick(){
clearInterval([Link]);
setStatus('Slide Show - Paused');
}
function handleNextClick(){
[Link] = [Link] + 1;
LoadProductManually([Link]);
setStatus('Slide Show - Manual');
}
function handlePrevClick(){
[Link] = [Link] - 1;
LoadProductManually([Link]);
setStatus('Slide Show - Manual');
}
function handleSkeebarChange(e){
[Link] = [Link];
LoadProductManually([Link]);
}
useEffect(()=>{
LoadProductManually(1);
},[])
return(
<div className="container-fluid d-flex justify-content-center">
<div className="card mt-3 p-2 w-50">
<div className="card-header text-center overflow-auto" style={{height:'80px'}}>
{[Link]}
<div className="fw-bold">
{status}
</div>
</div>
<div className="card-body">
<div className="row">
<div className="col-1 d-flex flex-column justify-content-center align-items-center">
<button onClick={handlePrevClick} className="bi btn btn-dark bi-chevron-left"></b
</div>
<div className="col-10 position-relative">
<div className="badge bg-danger text-white rounded rounded-circle p-3 fs-5 positi
<img width="100%" src={[Link]} height="300" />
<div>
<input value={[Link]} onChange={handleSkeebarChange} className="fo
</div>
</div>
<div className="col-1 d-flex flex-column justify-content-center align-items-center">
<button onClick={handleNextClick} className="bi btn btn-dark bi-chevron-right"></
</div>
</div>
</div>
<div className="card-footer text-center">
<button onClick={handlePlayClick} className="btn btn-warning bi bi-play"></button>
<button onClick={handlePauseClick} className="btn btn-danger bi bi-pause mx-2"></button>
</div>
</div>
</div>
)
}
Summary
- setTimeout()
- clearTimeout()
- setInterval()
- clearInterval()
Form Events
onSubmit
onReset
- They can trigger only with generic buttons like submit & reset.
</form>
Events Summary:
- Mouse Events
- Keyboard Events
- Button Events
- Clipboard Events
- Timer Events
- Form Events
Conditional Rendering in React
- You can render any component according to the state and situation
function handleAClick()
{
setComponent( <A/> );
}
function handleBClick()
{
setComponent( <B /> );
}
Ex: [Link]
import { useState } from "react"
return(
<div className="container-fluid p-5">
<h2>Home</h2>
<button onClick={handleLoginClick} className="btn btn-primary mx-2">Login</button>
<button onClick={handleRegisterClick} className="btn btn-success">Register</button>
<hr />
{component}
</div>
)
}
Syntax:
{
(isActive===true) ? <A /> : <B />
}
Ex: [Link]
import { useState } from "react"
function handleSignIn(){
setIsSignedIn(true);
}
function handleSignout(){
setIsSignedIn(false);
}
return(
<div className="container-fluid p-2">
<header className="d-flex border border-2 border-secondary justify-content-between align-items-ce
<div>
<span className="bi bi-amazon"> Amazon </span>
</div>
<div>
{
(isSignedIn===true)
?
<div>
<span className="badge fs-5 bg-danger text-white rounded rounded-circle">
<span className="bi bi-person"></span>
</span>
<button onClick={handleSignout} className="btn btn-link">Signout</button>
</div>
:
<div className="input-group">
<input className="form-control" type="text" placeholder="User Name" />
<button onClick={handleSignIn} className="btn btn-danger"> Signin</button>
</div>
}
</div>
</header>
</div>
)
}
22 January 2026
Controlled Components
properties. [ Props ]
Syntax:
function Component(props)
{
}
Syntax:
{
return(
<div {[Link]}> </div>
)
}
- Keys are dynamic references, you can define any name. But have to access only by specified name.
layouts.
Syntax:
function Component(props)
{
if([Link]==="value")
{
return( <A />);
}
else
{
return (<B /> );
}
}
Ex:
src/controlled-components/[Link]
src/components/home-demo/[Link]
import { Navbar } from "../../controlled-components/navbar";
Src/controlled-components/[Link]
Src/components/home-demo/[Link]
import { useState } from "react"
23 January 2026
- Props
Ans: It is a mechanism of transporting data from parent to child, where child can
be nested.
Parent can't send data to nested child it requires property drilling technique.
Parent => Child => Child
[level1] [level2]
- Context memory is accessible to any page that run within the context of parent.
- React provides a Context API, which allows to create a context for parent and
use the
<ContextName value={data}>
.... your child components ....
</ContextName>
- Context data is accessible only to the child components that run inside context
scope.
3. Child component can access and use the context memory by using
useContext() hook.
Ex: [Link]
return(
<div className="bg-dark text-white p-4">
<h4>Level-1 - Hello ! {context} </h4>
<Level2 />
</div>
)
}
return(
<div className="bg-warning text-white p-4">
<h4>Level-2 - Hi ! {context}</h4>
</div>
)
}
function handleNameChange(e){
setUName([Link]);
}
return(
<div className="container-fluid p-4 bg-danger text-white">
<h3>Parent Component <input onChange={handleNameChange} type="text" placeholder="User name" /> </
<UserContext value={uname}>
<Level1 />
</UserContext>
</div>
)
}
FAQ: Why you need context API if data can be transported from parent to child
using "Props"?
2. Login into your account to get API Key. [ My Profile => My API Keys ]
1318ca6725c69160d346c41fc0612596
3. Go to API docs
[Link] name}&appid=HYPERLINK
"[Link] key}
[Link]
1318ca6725c69160d346c41fc0612596&units=metric
Ex:
[Link]
import { WeatherDetails } from "./weather-details";
[Link]
import axios from "axios";
function LoadWeatherData(){
[Link](`[Link]
.then(response=>{
setWeatherObj([Link]);
})
}
useEffect(()=>{
LoadWeatherData();
},[])
return(
<div className="bg-light shadow shadow-lg p-3">
<h3>{[Link]}</h3>
<div className="fs-1 fw-bold">
{[Link]}°C
</div>
<div>
{[Link][0].description}
</div>
</div>
)
}
24 January 2026
1. Components/weather-app/[Link] [parent]
import { useState } from "react";
function handleCityChange(e){
setCityName([Link]);
}
function handleSearchClick(){
setCity(cityName);
setToggleDetails('d-block');
}
return(
<div className="container-fluid bg-secondary d-flex justify-content-center align-items-center" style=
<div className="p-4 bg-light w-50 rounded rounded-2" style={{height:'400px'}}>
<div>
<h3 className="text-center bi bi-cloud-rain"> Weather App</h3>
<div className="input-group">
<input onChange={handleCityChange} type="text" className="form-control" placeholder="
<button onClick={handleSearchClick} className="btn btn-warning bi bi-search"></button
</div>
<div className={`mt-4 ${toggleDetails}`}>
<WeatherDetails city={city} />
</div>
</div>
</div>
</div>
)
}
2. Components/weather-app/[Link] [child]
function LoadWeatherData(){
[Link](`[Link]
.then(response=>{
setWeatherObj([Link]);
})
}
useEffect(()=>{
LoadWeatherData();
},[props])
return(
<div className="bg-light shadow shadow-lg p-3">
<h3>{[Link]}</h3>
<div className="fs-1 fw-bold">
{[Link]}°C
</div>
<div>
{[Link][0].description}
</div>
</div>
)
}
1. Components/weather-app/[Link] [parent]
import { createContext, useState } from "react";
import { WeatherDetails } from "./weather-details";
function handleCityChange(e){
setCityName([Link]);
}
function handleSearchClick(){
setCity(cityName);
setToggleDetails('d-block');
}
return(
<div className="container-fluid bg-secondary d-flex justify-content-center align-items-center" style=
<div className="p-4 bg-light w-50 rounded rounded-2" style={{height:'400px'}}>
<div>
<h3 className="text-center bi bi-cloud-rain"> Weather App</h3>
<div className="input-group">
<input onChange={handleCityChange} type="text" className="form-control" placeholder="
<button onClick={handleSearchClick} className="btn btn-warning bi bi-search"></button
</div>
<div className={`mt-4 ${toggleDetails}`}>
<CityContext value={city}>
<WeatherDetails />
</CityContext>
</div>
</div>
</div>
</div>
)
}
2. Components/weather-app/[Link] [child]
function LoadWeatherData(){
[Link](`[Link]
.then(response=>{
setWeatherObj([Link]);
})
}
useEffect(()=>{
LoadWeatherData();
},[context])
return(
<div className="bg-light shadow shadow-lg p-3">
<h3>{[Link]}</h3>
<div className="fs-1 fw-bold">
{[Link]}°C
</div>
<div>
{[Link][0].description}
</div>
</div>
)
}
Ans: You can use various global state management techniques for storing data
globally
If you want to transport data from child to parent without explicit state
management
3. Events are object type, you can configure multiple events with key references.
Syntax:
4. Custom event of child component can store data, which can be any type data.
{
let data = any;
customEventName(data);
}
5. Data is transported using a trigger, which can any of default Synthetic Events.
function handleButtonClick()
{
customEventName(data);
}
6. Parent component can access the child event data using event binding
technique.
function parentHandler(e)
{
e => contains data from child.
}
Ex:
[Link]
import { useState } from "react";
function handleChildComponentClick(e){
setMsg(e);
}
return(
<div className="container-fluid text-white bg-danger p-4">
<h2>Parent Component - {msg}</h2>
<ChildComponent onChildClick={handleChildComponentClick} />
</div>
)
}
[Link]
function handleClick(){
let data = 'Hello from child';
onChildClick(data);
}
return(
<div className="p-4 bg-warning">
<h4>Child Component</h4>
<button onClick={handleClick} className="btn btn-light">Send Data to parent</button>
</div>
)
}
26 January 2026
a) Formik
function handleNameChange(e){
setUserName([Link]);
}
function handleAgeChange(e){
setAge([Link]);
}
function handleCityChange(e){
setCity([Link]);
}
function handleRegisterClick(e){
[Link]();
[Link](`User Name : ${uname}\nAge : ${age}\n City : ${city}`);
}
return(
<div className="container-fluid">
<h2>Register User</h2>
<form>
<dl>
<dt>User Name</dt>
<dd><input type="text" onChange={handleNameChange} /></dd>
<dt>Age</dt>
<dd><input type="text" onChange={handleAgeChange} /></dd>
<dt>Your City</dt>
<dd>
<select onChange={handleCityChange}>
<option>Select City</option>
<option>Delhi</option>
<option>Hyd</option>
</select>
</dd>
</dl>
<button onClick={handleRegisterClick}>Register</button>
</form>
</div>
)
}
Formik Library
- You can bind with any form and interact with the form data.
4. Make sure that every form element have a reference "name" that maps to
formik initialValues.
<input type="text" name="UserName" />
<form onSubmit={[Link]}>
</form>
Ex: [Link]
return(
<div className="container-fluid">
<h2>Register User</h2>
<form onSubmit={[Link]}>
<dl>
<dt>User Name</dt>
<dd><input type="text" onChange={[Link]} name="UserName" /></dd>
<dt>Age</dt>
<dd><input type="text" onChange={[Link]} name="Age" /></dd>
<dt>Your City</dt>
<dd>
<select onChange={[Link]} name="City" >
<option>Select City</option>
<option>Delhi</option>
<option>Hyd</option>
</select>
</dd>
<dt>Choose Gender</dt>
<dd>
<input type="radio" name="Gender" value="Male" onChange={[Link]} /> Male
<input type="radio" name="Gender" value="Female" onChange={[Link]} /> Fe
</dd>
</dl>
<button type="submit">Register</button>
</form>
</div>
)
}
Formik Validation
Custom Validation:
and methods.
- Formik can use your custom functions to validate the form field.
1. Write a function that collects form data, verifies the data and return
errors.
function ValidateUser(data)
{
var errors = { } ;
// your validation logic to validate data
return errors;
}
Ex:
[Link]
import { useFormik } from "formik";
function ValidateUser(userDetails){
var errors = {UserName:'', Age:'', City:'', Gender: ''};
if([Link]===0){
[Link] = 'User Name Required';
} else {
if([Link]<4){
[Link] = 'Name too short';
} else {
[Link] = '';
}
}
if([Link]===0){
[Link] = 'Age Required';
} else {
if(isNaN([Link])){
[Link] = 'Age must be a number';
} else {
[Link] = '';
}
}
if([Link]==='-1'){
[Link] = 'Please select your city';
} else {
[Link] = '';
}
return errors;
}
return(
<div className="container-fluid">
<h2>Register User</h2>
<form onSubmit={[Link]}>
<dl>
<dt>User Name</dt>
<dd><input type="text" onChange={[Link]} name="UserName" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Age</dt>
<dd><input type="text" onChange={[Link]} name="Age" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Your City</dt>
<dd>
<select onChange={[Link]} name="City" >
<option value='-1'>Select City</option>
<option value='Delhi'>Delhi</option>
<option value='Hyd'>Hyd</option>
</select>
</dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Choose Gender</dt>
<dd>
<input type="radio" name="Gender" value="Male" onChange={[Link]} /> Male
<input type="radio" name="Gender" value="Female" onChange={[Link]} /> Fe
</dd>
</dl>
<button type="submit">Register</button>
</form>
</div>
)
}
27 January 2026
- Formik
- useFormik()
- Validation
Yup library for Validation
2. You can import only the required validation service or all services from
library.
import { required, min, max, ... } from "yup";
(or)
import * as yup from "yup";
Ex:
[Link]
return(
<div className="container-fluid">
<h2>Register User</h2>
<form onSubmit={[Link]}>
<dl>
<dt>User Name</dt>
<dd><input type="text" onChange={[Link]} name="UserName" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Age</dt>
<dd><input type="text" onChange={[Link]} name="Age" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Mobile</dt>
<dd><input type="text" onChange={[Link]} name="Mobile" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Your City</dt>
<dd>
<select onChange={[Link]} name="City" >
<option value='-1'>Select City</option>
<option value='Delhi'>Delhi</option>
<option value='Hyd'>Hyd</option>
</select>
</dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Choose Gender</dt>
<dd>
<input type="radio" name="Gender" value="Male" onChange={[Link]} /> Male
<input type="radio" name="Gender" value="Female" onChange={[Link]} /> Fe
</dd>
</dl>
<button type="submit">Register</button>
</form>
</div>
)
}
Validation State
a) Input State
b) Form State
- Form State is the process of verifying all fields simultaneously at the same time.
- Formik provides both input and form state validation.
- touched returns
true
- dirty returns
true
- isValid returns
true
- errors returns a object the comprises of all fields and their error messages.
Syntax:
Syntax:
[Link]([Link]) => returns all error messages [ ].
a) onChange
b) onBlur
c) onSubmit
a) handleChange
b) handleBlur
c) handleSubmit
Ex:
import { useFormik } from "formik";
return(
<div className="container-fluid">
<h2>Register User</h2>
<form onSubmit={[Link]}>
<dl>
<dt>User Name</dt>
<dd><input type="text" {...[Link]('UserName')} name="UserName" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Age</dt>
<dd><input type="text" onChange={[Link]} name="Age" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Mobile</dt>
<dd><input type="text" onChange={[Link]} name="Mobile" /></dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Your City</dt>
<dd>
<select onChange={[Link]} name="City" >
<option value='-1'>Select City</option>
<option value='Delhi'>Delhi</option>
<option value='Hyd'>Hyd</option>
</select>
</dd>
<dd className="text-danger">{[Link]}</dd>
<dt>Choose Gender</dt>
<dd>
<input type="radio" name="Gender" value="Male" onChange={[Link]} /> Male
<input type="radio" name="Gender" value="Female" onChange={[Link]} /> Fe
</dd>
</dl>
<button type="submit" disabled={([Link])?false:true} className="mx-2">Register</butto
<button className={([Link])?'d-inline':'d-none'}>Save</button>
<div style={{color:'red'}} className={([Link])?'d-none':'d-block'}>
<h3>Please check the following errors in form</h3>
<ul>
{
[Link]([Link]).map(error=> <li key={error}> {error} </li>)
}
</ul>
</div>
</form>
</div>
)
}
Note: Hooks are not allowed in class components. You can't use
Reack-Hook-Form
[Link]
28 January 2026
- Formik
- Yup
- Validation
- Validation Schema
Formik Components:
<Formik>
<Form>
<Field>
<ErrorMessage>
Syntax:
<Formik initialValues={ } validate={ } validationSchema={ } onSubmit={ }>
<Form>
<Field type="text | email | number | date.." name="FieldName" />
<ErrorMessage name="FieldName" />
</Form>
</Form>
<Form> Formik Form Component
<form> HTML Form
- You can capture the form state and handle form state validations.
Syntax:
<Formik>
{
formik => <Form> </Form>
[Link], dirty, touched etc.
}
</Formik>
Ex:
[Link]
Features:
1. Performant
- It is light weight as it uses less memory.
- It is modular as it includes only the services required for situation.
- It is faster in rendering output.
4. Every service is not required for an application. You have to find exactly relative
29 January 2026
- It verifies the keys at runtime, and if any key not found then it returns errors.
-You can avoid runtime errors and set keys as "undefined" by using "?" Null
reference character.
Syntax:
var product = { name: "TV", rating: { rate : 3.5 } };
[Link]( [Link]); // 3.5
[Link]( [Link]); // undefined
[Link]( [Link]); // rating not defined [vendor] error.
[Link]( [Link]?.rating); // undefined
Ex: [Link]
return(
<div className="container-fluid">
<form onSubmit={handleSubmit(submit)}>
<h3>Register User</h3>
<dl>
<dt>User Name</dt>
<dd><input type="text" {...register("UserName", {required:true, minLength:4})} name="User
<dd className="text-danger">
{
([Link]?.type==="required")? <span>User Name Required</span> : <span></s
&&
([Link]?.type==="minLength")? <span>Name too short</span> : <span></span
}
</dd>
<dt>Mobile</dt>
<dd>
<input type="text" {...register("Mobile", {required:true, pattern:/\+91\d{10}/})} nam
</dd>
<dd className="text-danger">
{
([Link]?.type==="required")? <span>Mobile Required</span>: <span></span>
&&
([Link]?.type==="pattern")? <span>Invalid Mobile +91 10 digits</span> : <span>
}
</dd>
</dl>
<button type="submit">Submit</button>
</form>
</div>
)
}
return(
<div className="container-fluid">
<form onSubmit={handleSubmit(submit)}>
<h3>Register User</h3>
<dl>
<dt>User Name</dt>
<dd><input type="text" {...register("UserName", {required:true, minLength:4})} name="User
<dd className="text-danger">
{
([Link]?.type==="required")? <span>User Name Required</span> : <span></s
&&
([Link]?.type==="minLength")? <span>Name too short</span> : <span></span
}
</dd>
<dt>Mobile</dt>
<dd>
<input type="text" {...register("Mobile", {required:true, pattern:/\+91\d{10}/})} nam
</dd>
<dd className="text-danger">
{
([Link]?.type==="required")? <span>Mobile Required</span>: <span></span>
&&
([Link]?.type==="pattern")? <span>Invalid Mobile +91 10 digits</span> : <span>
}
</dd>
<dt>Upload Photo</dt>
<dd>
<input type="file" /> <button className="btn d-inline btn-link"> upload more</button>
</dd>
</dl>
<button type="submit">Submit</button>
</form>
</div>
)
}
What's New in React 19x Forms:
1. FormData
Syntax:
let formdata = new FormData(formReference);
function handleSubmit(e)
{
let formdata = new FormData([Link]); // sends form reference.
[Link](key)
[Link](key)
[Link](key)
.keys()
.values()
.entries()
etc..
}
Ex: [Link]
function handleSubmit(e){
[Link]();
let formdata = new FormData([Link]);
[Link](`User Name : ${[Link]('UserName')}\nMobile : ${[Link]('Mobile')}`);
}
return(
<div className="container-fluid p-3">
<form onSubmit={handleSubmit}>
<dl>
<dt>Name</dt>
<dd><input type="text" name="UserName" /></dd>
<dt>Mobile</dt>
<dd><input type="text" name="Mobile" /></dd>
</dl>
<button type="submit">Submit</button>
</form>
</div>
)
}
2. useRef
- It is a react hook.
- It is good for values used inside process but not for rendering in UI.
- Every HTML form element can be configured with "ref" property, which maps to
reference memory.
Syntax:
const nameRef = useRef(null);
<input type="text" name="UserName" ref={ nameRef } />
Syntax:
[Link] // refers to entire form element <input>
[Link] // refers to input value
3. useFormState()
4. useFormAction()
- These are new React 19 hooks for handling server side actions.
- A client component can collect data from form and submit to any server
component
30 January 2026
a) Data Binding
b) Event Binding
c) State Management
d) Caching
e) Model Binding
f) Routing etc.
- User friendly URL's allow user to query any content directly from address bar.
[Link]
=apple
[Link]
- SEO friendly URL allows web crawlers to find the exact location of user in page.
- Routing implicitly uses AJAX, which allows to load new content into page without reloading the page.
- In SPA [Single Page Application] user can stay on one page and can access
everything
on to the page.
b) Client Side
- Server Side routing is used in server frameworks, it can be in server side app or
API.
- Client side libraries and frameworks can use routing for navigation.
<Routes>
<Route>
<Link>
<Outlet>
Syntax:
<BrowserRouter>
<Routes>
<Route path={ } element={ } children={ } />
</Routes>
</BrowserRouter>
Ex:
[Link]
import { BrowserRouter, Route, Routes, Link } from "react-router-dom";
31 January 2026
<BrowserRouter>
<Routes>
<Route>
<Link>
Route Path:
Route Parameters:
Syntax:
<Route path="products/:category/:product/:rating" element={ <Component /> } />
- You can access the route parameters by using the hook "useParams()".
Ex:
1. [Link]
import { BrowserRouter, Route, Routes } from "react-router-dom";
2. [Link]
useEffect(()=>{
LoadCategories();
},[])
return(
<div className="container-fluid mt-5">
<h4>Shopping Home</h4>
<ul className="list-group w-25">
{
[Link](category=>
<li className="list-group-item my-2 list-group-item-secondary" key={category}> <span>
)
}
</ul>
</div>
)
}
3. [Link]
import axios from "axios";
function LoadProducts(){
[Link](`[Link]
.then(response=>{
setProducts([Link](product=> [Link]===[Link]));
})
}
useEffect(()=>{
LoadProducts();
},[])
return(
<div className="container-fluid mt-4">
<h4>Products</h4>
<div className="d-flex flex-wrap flex-row" style={{width:'600px'}}>
{
[Link](product=>
<div className="card m-2 p-2" style={{width:'130px'}} key={[Link]}>
<div className="card-header">
<img className="card-img-top" src={[Link]} height="50" />
</div>
<div className="card-footer">
<Link to={`/details/${[Link]}`} className="btn btn-dark w-100" > Details </Link>
</div>
</div>
)
}
</div>
<Link to="/">Back to Categories</Link>
</div>
)
}
4. [Link]
function LoadProduct(){
[Link](`[Link]
.then(response=>{
setProduct([Link]);
})
}
useEffect(()=>{
LoadProduct();
},[])
return(
<div className="container-fluid mt-4">
<h4>Details</h4>
<dl>
<dt>Title</dt>
<dd>{[Link]}</dd>
<dt>Preview</dt>
<dd>
<img src={[Link]} width="200" height="200" />
</dd>
<dt>Price</dt>
<dd>{[Link]('en-us', {style:'currency', currency:'USD'})}</dd>
</dl>
<Link to={`/products/${[Link]}`}>Back to Products</Link>
</div>
)
}
02 February 2026
Route Parameters
Child Routes:
Syntax:
<Route path="parent" element={ <Parent /> } >
<Route path="child" element= { <Child /> } />
... multiple child routes ...
</Route>
</Route>
Ans: Absolute route refers to individual path. It can access and render component
individually.
[Link]
<Route path="details" ... />
<Link to="details"> Details </Link> Relative
[Link]
<Link to="/details"> Details </Link> Absolute
[Link]
Relative route refers to a path that is accessed with in the context of current.
It can referred as child route.
Ans : It refers to the target location where the resulting markup is rendered.
The child route target [element] is rendered at outlet position.
Ans:
- HTML form can submit data on GET and POST requests.
- Data will be in FormData when you submit on POST request.
- Data will be in Query String when you submit on GET request. - Query String in React can be appended to
Route path as a key and value
collection.
Syntax:
[Link] ? Key = value & key = value
- React can access the search parameters by using useSearchParams() hook.
- In Actual DOM you can access query string using "[Link]" and convert
into parameters collection using URLSearchParams().
Syntax:
let [params] = useSearchParams();
[Link]( key );
To-DO Application
04 February 2026
a) MUI-Core
b) MUI-X
c) Templates
d) Design Kits
4. Events for components are same as you defined for JSX components.
[Synthetic Events]
<TextField onChange={ handleChange } />
<Button onClick= {handleClick } />
Ex:
[Link]
return(
<div className="container-fluid">
<div className="mt-2 row">
<div className="col">
<h3>Bootstrap Login</h3>
<form className="w-50">
<div className="mb-2">
<label className="form-label">User Name</label>
<div>
<input type="text" className="form-control" />
</div>
</div>
<div className="mb-2">
<label className="form-label">Password</label>
<div>
<input type="password" className="form-control" />
</div>
</div>
<div>
<button className="btn btn-primary w-100">Login</button>
</div>
</form>
</div>
<div className="col">
<h3>MUI Login</h3>
<form className="w-50" onSubmit={[Link]}>
<div className="mb-2">
<TextField onChange={[Link]} name="UserName" className="w-100" type
</div>
<div className="mb-2">
<TextField onChange={[Link]} name="Password" className="w-100" type
</div>
<div>
<Button type="submit" className="w-100" variant="contained" color="primary"> Logi
</div>
</form>
</div>
</div>
</div>
)
}
TO-DO Application
- User views the dashboard with all scheduled appointments after login.
- Login credentials are managed with cookies. User session is maintained with
cookie.
a) Add
b) Edit
c) Delete
Users
UserId [PK]
UserName
Password
Email
Appointments
Title
Description
Date
Id [PK]
UserId [FK]
[Physical Model]
Users
UserId [string]
UserName [string]
Password [string]
Email [string]
Appointments
Id [number]
Title [string]
Description [string]
Date [date]
UserId [string]
2. Create a new file by name "[Link]" and add into project root folder.
{
"users": [ ],
"appointments: [ ]
}
Note: Make sure that every record has an "id" in JSON data.
05 February 2026
1. Go to [Link] file
3. Every time you can run the following command from terminal
> npm run api
GET /users
GET /appointments
GET /appointments/id ]
POST /users
POST /appointments
PUT /users/id
PUT /appointments/id
DELETE /users/id
DELETE /appointments/id
- It is the process of navigating user from one route to another according to the
state
and situation.
navigation.
Syntax:
let navigate = useNavigate();
navigate("/path");
06 February 2026
- There are various client side state management techniques, which we can use to
a) Query String
b) Local Storage
c) Session Storage
d) Cookies
- Cookies can be
a) In memory : Temporary
b) Persistent : Permanent
- React requires a 3rd party library to manage cookies with virtual DOM.
<CookiesProvider>
<ToDoIndex />
</CookiesProvider>
- It is responsible for locating the value in memory and inject into component.
Syntax:
cookies[ 91name' ] // returns the cookie value
setCookie( 91name', 91value', { expires: date } );
removeCookie(91name');
07 February 2026
HYPERLINK "[Link]
hGroup/react-demo-app-6pm-2026
09 February 2026
[Link](`[Link]
useFormik( {
initialValues : {
id: [Link],
title: [Link],
}
})
- Initialization of data into formik is default disabled. You have enable initialization.
useFormik( {
initialValues: { },
onSubmit: () => { },
enableReinitialize : true
})
- Submit action must use "put()" method for updating the details
onSubmit : ( appointment ) => {
[Link]( `[Link] appointment );
}
10 February 2026
- Creation
- Mount
- Update
- Unmount
- Lazy loading is the mechanism of loading only the content required for situation.
- It is heavy on application.
- You can enable lazy loading, so that it loads only the chunk of JS bundle that is
</Suspense>
Note: Make sure that the component loaded with lazy technique is a
default component.
Syntax:
export default function Component() { } => can load lazy
export function Component() { } => can't load lazy
Ex: [Link]
React Hooks
functionality in application.
a) Reusability
b) Extensibility
c) Maintainability
d) Testability etc.
- React has several pre-defined services and allows to create custom services.
- Service comprises of
a) consumer
b) provider
c) subscriber
d) injector etc.
- Provider is responsible for locating and injecting the services into components.
Custom Hooks:
11 February 2026
- What is Service?
- DI
Custom Hooks
- Hook is a function.
- Hook function name must start with "use" and must be in camelCase.
function useCaptcha()
{
}
- You can't access and use a hook inside any block, you can use only in React
FAQ: Why to use a hook, if the same can be achieved using function?
Ans: Single Call is a design pattern used to create an object for every request.
Single Ton is a pattern where object is created for first request and the same
is used across requests.
Ex:
1. Src/hooks/[Link]
2. [Link]
import axios from "axios";
function LoadUsers(){
axios('[Link]
.then(response=>{
setUsers([Link]);
})
}
useEffect(()=>{
LoadUsers();
},[])
return(
<div className="container-fluid">
<form onSubmit={[Link]} className={`p-4 ${[Link]}`}>
<h4 className="bi bi-person-fill"> User Login</h4>
<dl>
<dt>User Id</dt>
<dd><input type="text" onChange={[Link]} name="user_id" className="form-cont
<dt>Password</dt>
<dd><input type="password" onChange={[Link]} name="password" className="form
<dt>Verify Code</dt>
<dd>{code}</dd>
</dl>
<button type="submit" className="btn btn-primary w-100">Login</button>
<div className="mt-4">
<Link to="/register">New User Register</Link>
</div>
</form>
</div>
)
}
- Every custom hook can have the phases like mount and unmount.
- Hook mount is executed while loading and unmount, while changing hook.
Ex: src/hooks/[Link]
useEffect(()=>{
[Link](url)
.then(response=> setData([Link]));
},[url])
return data;
}
[Link]
import { useFetchData } from "../hooks/use-fetchdata";
<ul>
{[Link](appointment=><li key={[Link]}>{[Link]}</li>)}
</ul>
12 February 2026
1. useEffect()
Syntax:
useEffect( ( )=> {
// actions on mount
return ()=> {
// actions on unmount
}
},[dependencies])
Ex: [Link]
useEffect(()=>{
[Link]('Login Mounted');
return()=>{
[Link]('Login Unmounted');
}
},[])
return(
<div>
<h3>Login</h3>
</div>
)
}
export function Register(){
useEffect(()=>{
[Link]('Register Mounted');
return()=>{
[Link]('Register Unmounted');
}
},[])
return(
<div>
<h3>Register</h3>
</div>
)
}
function handleLoginClick(){
setView(<Login />);
}
function handleRegisterClick(){
setView(<Register />);
}
return(
<div className="container-fluid">
<div className="p-5">
<button onClick={handleLoginClick}>Login</button>
<button onClick={handleRegisterClick}>Register</button>
<hr />
{view}
</div>
</div>
)
}
FAQ's:
1. Can we define multiple mount phases for a component?
A. Yes. You can define multiple useEffects() in a component.
2. Why we need multiple useEffects() in a component?
A. To render and define various actions on mount.
You can conditionally mount different actions for a component.
2. useState()
- It uses the component local state created for component.
Syntax:
const [ get, set ] = useState( value );
3. useContext()
Syntax:
let ContextName = createContext(null);
let context = useContext(ContextName);
<ContextName value={ data } >
... context scope .. for child components ...
</ContextName>
- You can carry data from child to parent by using Custom Events.
4. useRef()
Syntax:
let thread = useRef(null);
[Link] = value / function;
5. useMemo()
- Round trip is the process of requesting content every time from server.
Syntax:
useMemo( ()=>{
return data;
},[dependencies])
var data = useMemo( ()=> { return data }, [ dependencies ]);
[Link]().filter().sort() etc..
6. useCallback()
- It is same as useMemo().
Syntax:
useCallback(()=>{ }, [ dependency ])
const LoginClick = useCallBack( ()=>{
setCookie();
other actions on login..
},[cookies])
<button onClick={ LoginClick } > Login </button>
7. useReducer
13 February 2026
1. useEffect
2. useState
3. useRef
4. useContext
5. useMemo
6. useCallback
7. useOutletContext [react-router-dom]
1. Go to [Link]
previous:
function LoadAppointments() { }
new:
const LoadAppointments = useCallback(()=>{
// axios to load all appointments.
},[])
useEffect(()=>{
LoadAppointments();
},[])
previous : Load appointments is filtering user details, remove filter and load
all appointments.
new:
const userAppointments = useMemo(()=>{
return [Link]();
},[appointments, cookies])
- Load userAppointments in table.
[Link]( appointment=> <tr> </tr> )
2. Go to [Link]
},[cookies])
2. Todo-dashboard is a parent route with outlet, Every route outlet has a default
context
<Outlet context={ {searchString} } />
8. useLayoutEffect()
Syntax:
useLayoutEffect(()=>{
// styles to control layout
},[dependencies])
9. useInsertionEffect()
Syntax:
useInsertionEffect(()=>{
// inject libraries for component
},[])
10. useReducer
14 February 2026
State
is responsible for accessing data from store and providing to component UI.
-
Reducer
identifies the actions [trigger] in UI and update data into store.
- Dispatch
is responsible for sending the data from component to store.
let initialState = {
likes: 0
}
return(
<div className="container-fluid">
<div className="mt-4 w-50 card">
<div className="card-header">
<h2>Naresh IT Live</h2>
</div>
<div className="card-body">
<iframe src="[Link] className="w-100" height="300"></
</div>
<div className="card-footer">
<button onClick={handleLikeClick} className="btn btn-warning bi bi-hand-thumbs-up"> [{sta
</div>
</div>
</div>
)
}
Redux JS
- It is a Javascript library for global application state management.
- It provides a toolkit for developers.
- Toolkit is a tool chain that provides features for building, debugging and testing
application state.
- It provides complete environment for enterprise based applications.
- It provides 2 libraries
a) Redux Core
b) Redux Toolkit
- Redux Core is a minimal library with reducers and not recommended for large scale
applications.
- Redux Toolkit is professional with all features from design to test.
16 February 2026
- Slicer configures initial state, which defines the data to handle in application
memory.
- It also configures reducer, which defines the actions to perform and the
Syntax:
const SlicerName = createSlice({
name : "SlicerName",
initialState,
reducer: {
action1: (state, action) => { [Link] },
action2: (state, action) => { [Link] }
}
})
export const { action1, action2 } = [Link];
export default [Link];
- In [Link] you have to define initial state, which specifies the data.
let initialState = { };
3. Create a store
src/store/[Link]
- It is global storage.
- It stores your data in application memory and provides to all sessions in
application.
Syntax:
export default createStore()
{
reducer: { SlicerName }
}
- Store is a service.
- It uses a provider.
</Provider>
- Import actions from reducer [slicer] and dispatch the payload into store.
Syntax:
Note : To track and debug Redux install the extension for your browser
"Redux DevTools".
6. You can access and use store from component by using store reference
import store from "../store/[Link]";
[Link]().your_data
17 February 2026
Slicer
createSlice()
Store
configureStore / createStore
Reducers
useDispatch()
Redux DevTools
useOptimistic()
useActionState()
useFormState()
Class Components:
1. A class component must extend
a) [Link]
(or)
b) [Link]
Syntax:
export class Name extends [Link] (or) [Link]
{
}
-
PureComponent
avoids re-renders.
2. Call the super constructor in derived class
export class Name extends [Link]
{
constructor() {
super();
}
}
3. It must return JSX element by using
render()
method.
export class Name extends [Link]
{
constructor() {
super();
}
render() {
return(
< > JSX </>
)
}
}
[Link]()
" method.
- You can access state by using
"[Link]".
handleInsertClick(){
[Link]({msg: 'Record Inserted'});
}
render(){
return(
<div className="container mt-3">
<h2>Class Component</h2>
<button onClick={[Link]} >Insert</button>
<p>{[Link]}</p>
</div>
)
}
}
18 February 2026
- State
- Event Binding
Ex:
handleInsertClick(){
[Link]({msg: 'Record Inserted'});
}
handleUpdateClick(){
[Link]({msg: 'Record Updated'});
}
render(){
return(
<div className="container mt-3">
<h2>Class Component</h2>
<button onClick={[Link]} >Insert</button>
<button onClick={()=> [Link]()}>Update</button>
<p>{[Link]}</p>
</div>
)
}
}
<Formik>
<Form>
<Field>
<ErrorMessage>
- Class components can use built-in Formik components with validation schema
Syntax:
<Formik initialValues={ } validationSchema={ } onSubmit={ }>
<Form>
<Field>
<ErrorMessage>
</Form>
</Formik>
Syntax:
Ex:
controlled-components/[Link]
[Link]
handleInsertClick(){
[Link]({msg: 'Record Inserted'});
}
handleUpdateClick(){
[Link]({msg: 'Record Updated'});
}
render(){
return(
<div className="container mt-3">
<Toolbar brand='Amazon' items={['Home','Shop','Offers']} />
<h2>Class Component</h2>
<button onClick={[Link]} >Insert</button>
<button onClick={()=> [Link]()}>Update</button>
<p>{[Link]}</p>
</div>
)
}
}
FAQ: Can we access a function component in class component & vice versa?
Ans: Yes. Class can have a function, but it can be a class member.
Syntax:
class Demo
{
function f1() { } // invalid
}
class Demo
{
print() {
function f1(){ } // valid
}
}
Note: Component Life Cycle Hooks are different from React Hooks?
- Life Cycle Hooks [Classes]
componentWillMount()
componentDidMount() etc..
- React Hooks [Functions]
useState()
useEffect()
useContext() etc..
Ans:
- It is not strongly typed.
- It is not implicitly strictly typed.
- It is not an OOP language.
- It is an OBPS. [Object Based Programming System]
- Extensibility issues
- No Dynamic Polymorphism
- No Code Level Security
TypeScript
- It is an OOP language.
- It is a Microsoft Language.
- Typescript is trans compiled into Javascript.
Typescript Architecture
19 February 2026
1. Core Compiler
etc.
2. Standalone TS compiler
3. Language Service
- It is a set of factories with functions & values required for typescript application.
- It is OS relative library.
5. Shims Library
6. TS Server
Typescript Language:
20 February 2026
1. Variables
2. Data Types
3. Operators
4. Statements
5. Functions
6. OOPS
Syntax:
Ex:
- Typescript supports type inference. The data type can be determined according
to
- If value is not defined then the default is "any" type, which is the root for all
types.
- All number methods, string methods and other manipulations on primitive types
are
same as in Javascript.
isNaN(price) etc..
[Link]
[Link]()
[Link]() etc..
1. Array
- Typescript array can handle various types like Javascript and can also restrict
Syntax:
let names:string[] = new Array();
let names:string[] = [ ];
let values:any[] = [ ];
values[0] = 10;
values[1] = "A";
values[2] = true;
- You can't initialize various types of values using an array constructor even when
the data type is any.
- Array can configure union of types. However it will not allow to initialize all types
2. Object
Syntax:
character.
Syntax:
- It supports read-only properties, you can initialize a value but can't assign.
Syntax:
Price: 3000
}
Ex:
EX:
Syntax:
let data: Map<key_datatype, value_datatype> = new Map()
21 February 2026
- Primitive Types
- Non Primitive
- Union of Types
- Type Inference
- Tuple
- Map Generic
Date Type:
Syntax:
let departure:Date = new Date("yy-mm-dd hrs:min:sec");
Syntax:
let pattern:RegExp = /^\d{10}$/;
Syntax:
function Name(params:dataType) : void | dataType
{
return value; // if not void
}
Ex:
function Add(a:number, b:number) : number
{
return a + b;
}
- You can configure optional parameters using "?", but it requires to verify by
using
undefined.
Syntax:
function Name(param1:type, param2?type)
{
if(param2) {
// when defined
}
}
Ex:
- Rest parameter is defined as array. You can allow various types of arguments
Syntax:
function Name(...params:any[]) : void
{
}
Name(1, 91TV, true);
- Function currying and higher order functions require the type defined using
"Function" interface.
Syntax:
function Name(success:Function, failure:Function) : Function
{
}
Ex:
Typescript OOP
1. Contracts
Syntax:
interface Name
{
property: type;
method(): type;
}
Ex:
interface IProduct
{
Name:string;
Price:number;
Qty:number;
Total():number;
Print():void;
}
let product:IProduct = {
Name: 'TV',
Price: 34000,
Qty: 2,
Total: function(){
return [Link] * [Link];
},
Print: function(){
[Link](`Name=${[Link]}`);
}
}
[Link]();
Syntax:
interface Contract1
{
}
Ex:
interface ICategory{
CategoryName: string;
}
interface IVendor{
VendorName:string;
}
2. Components
- Contracts
interface
- Component
class
a) property
b) accessor
c) constructor
d) method
Access Modifiers:
a) public
- It is default access modifier.
- It allows access from any location and through any object.
- You can access with super or derived class object.
b) private
- It is accessible only with in the defined class.
c) protected
- It is accessible within the defined class.
- It is accessible outside class but inside derived class and only by using
derived class reference.
Ex:
class Product
{
public Name:string = "TV";
private Price:number = 53000;
protected Stock:boolean = true;
}
class Derived extends Product
{
public Print(obj1:Derived){
[Link];
[Link];
}
}
let obj = new Derived();
[Link];
3. Templates
- Template comprises of pre-defined design and logic, which you can customize
- Templates are used to hide the structure and provide only functionality.
development.
- The process of hiding the structure and providing only functionality is known as
Abstraction.
Syntax:
Ex:
interface ProductContract
{
Name:string;
Price:number;
Qty:number;
Total():number;
Print():void;
}
4. Generics
- A type safe member is open for any type and strongly typed for specific data
type.
- In OOP
Syntax:
function Name<Type>(params:Type): Type
{
}
Syntax:
class Name<T>
{
constructor(param:T) { }
property : T;
method<T>(): T { }
}
Ex:
interface MySQL
{
host:string;
user:string;
password:string;
database:string;
}
interface MongoDB
{
url:string;
}
class Database<T>
{
constructor(connectionString:T){
for(var property in connectionString){
[Link](`${property} : ${connectionString[property]}`);
}
}
}
Ex:
interface IProduct
{
id:number;
title:string;
price:number;
}
interface IEmployee{
firstName:string;
designation:string;
}
class FetchAPI<T>
{
constructor(response:T){
[Link](response);
}
}
Enum, Namespace
24 February 2026
- Generic
- Templates
Enumeration
- It is a collection of constants.
- Constant can be number, string or expression.
Syntax:
enum Name
{
Key = value,
Key = value
}
Syntax:
[Link]
- It supports reverse mapping, which allows to access key with reference of value.
Syntax:
Name[value]
Ex:
enum StatusCodes
{
Found=200,
NotFound = 404,
ClientError,
Error = "Something went wrong",
Status = 505,
A = 10,
B = 20,
C = A + B
}
[Link](`${[Link]} : ${StatusCodes[404]}`);
Namespace
Syntax:
namespace Parent
{
namespace Child
{
// contracts
// templates
// components
// functions
// values
}
}
[Link]
Ex:
1. Library/contracts/[Link]
namespace Project
{
export namespace Contracts
{
export interface ProductContract
{
Name:string;
Price:number;
Qty:number;
Total():number;
Print():void;
}
}
}
2. Library/template/[Link]
///<reference path="../contracts/[Link]" />
namespace Project
{
export namespace Templates
{
export abstract class ProductTemplate implements ProductContract
{
public Name:string = "";
public Price:number = 0;
public Qty:number = 0;
public abstract Total():number;
public abstract Print():void;
}
}
}
3. Library/components/[Link]
///<reference path="../templates/[Link]" />
namespace Project
{
export namespace Components
{
export class ProductComponent extends ProductTemplate
{
Name = "TV";
Price = 45000;
Qty = 2;
Total(){
return [Link] * [Link];
}
Print(){
[Link](`Name=${[Link]}\nPrice=${[Link]}\nQty=${[Link]}\nTotal=${[Link](
}
}
}
}
4. App/[Link]
4. Configuring files
.tsx => components, hooks, uncontrolled, main, store, slicer
.ts => contract, templates
function Login() : [Link]
{
return( <div> </div>);
}
State:
Syntax:
- You can access the values directly from state if it contains initialization.
{ [Link]() }
{ products?.map() }
Contracts:
Libraries:
Ex:
1. Src/contract/[Link]
export interface FakestoreContract
{
id:number;
title:string;
price:number;
description:string;
image:string;
rating:{rate:number, count:number};
category:string;
}
2. Components/[Link]
import { useEffect, useState } from "react"
useEffect(()=>{
[Link]('[Link]
.then(response=>{
setProducts([Link]);
})
},[])
return(
<div style={{padding:'20px'}}>
<h3>Products</h3>
{
products?.map(product=> <p key={[Link]}>{[Link]}</p>)
}
</div>
)
}
25 February 2026
Syntax:
Syntax:
- React applications that change their routes regularly and need frequent
extensions
3. Configure routes
4. Go to "[Link]"
Ex: routes/[Link]
2. Add "[Link]"
Ex: [Link]
const routes:RouteObject[] = [
{
path:'',
element: <></>
}
]
export const router = createBrowserRouter(routes);
Typescript Video Library Project
Modules:
1. Admin
- Edit Video
- Delete Video
2. User
- Can register
- Can Login
- User Dashboard
- React for UI
- Express JS middleware
For Backend :