SlideShare a Scribd company logo
React JS
ReactJS is a component-based JavaScript
library used to build dynamic and interactive
user interfaces.
01
React JS
02
It simplifies the creation of single-page applications (SPAs) with a focus on
performance and maintainability.
 It is developed and by Facebook & now maintained by community developer.
 Uses a virtual DOM for faster updates.
 Supports a declarative approach to designing UI components.
 Ensures better application control with one-way data binding.
What is react component ?
03
 components are the building blocks of a React application
 A component is essentially a reusable, self-contained piece of UI.
 React allows you to break down a complex UI into smaller, manageable pieces
 React offers two main types of components: functional components and class
components.
Tools Need
04
First react project using vite
05
 Vite is a modern frontend build tool that provides a faster development
experience & development server experience for modern web projects .
npm create vite@latest
Why vite ?
06
Why vite ?
07
 Vite is a fast, modern build tool with Hot Module Replacement features
created by the founder of Vue.js Evan You ,
 designed for optimized development and production workflows.
Top Reasons to Use Vite
⚡ 1. Ultra-Fast Development Server
 ite uses native ES modules to serve files directly to the browser.
Why vite ?
08
 No bundling during development = instant startup.
 Changes in code are reflected almost instantly with Hot Module Replacement
(HMR).
⚡ 1. Uses Rollup under the hood for efficient bundling.
 Automatically splits code, removes unused code (tree-shaking), and minifies output.
📦 2. Optimized Production Build
Why vite ?
09
🚀 3. Out-of-the-Box Modern Features
 ES6+ support, TypeScript, JSX, CSS modules, PostCSS, and more — no extra
config needed.
 Built-in support for .env files, dynamic imports, and asset handling.
🎯 4. Minimal Config & Easy Setup
 Create a working project in seconds using:
npm create vite@latest
Why vite ?
10
💡 5. Great DX (Developer Experience)
 Cleaner error messages.
 Fast feedback loop = higher productivity.
 Plugins and integrations are simpler.
🧩 6. Framework Agnostic, But Optimized
 Works great with Vue 3, React, Svelte, Lit, Solid, and even plain JavaScript.
 Official templates for each framework.
Why vite ?
11
🔄 7. Fast Refresh & HMR
 When you save a file, only the module that changed is updated in the browser.
 This leads to a smoother and faster dev workflow compared to traditional
bundlers.
🌍 8. Strong Community & Ecosystem
 Backed by Evan You (Vue’s creator).
 Active plugin ecosystem.
 Popular among frontend frameworks and open source tools.
Run React Project
12
npm run dev npx vite
OR
For build
npm run build npx vite build
OR
vite.config.js
13
npm run dev npx vite
OR
For build
npm run build npx vite build
OR
React Project Structure
14
Distribution Node Modules
Public Src
main.jsx node_modules
.gitignore App.jsx
useRef Hook
15
built-in React Hook that returns a mutable reference object (ref) that persists
across renders
Accessing and manipulating DOM elements without triggering re-renders.
Persisting values across renders without causing re-renders.
Storing previous state values to compare changes between renders
Optimizing performance by avoiding unnecessary state updates
useRef Hook
16
useRef Hook
17
useRef Hook Working With Attribute
18
useRef Working With Input Element
19
[Hook] useRef Working With CSS Class
20
[Hook] useRef Working With Persisted Mutable Property
21
The value of mutable property is only
updated
component is not re-rendered
[Hook] useRef Caching Expensive Computation
22
useRef holds a persistent value that survives across renders
but doesn’t cause re-renders when updated
When can use it
 When you need to re-use result multiple times without re-rendering
 Cache expensive computations
 Store previous values
 Avoid recalculating something unnecessarily
 Preventing reinitialization of complex objects
Where can use it
 For API Calling
 Avoiding duplicate form submissions
[Hook] useRef Caching Expensive Computation
23
If state change occure then re-render the component
24
The React useState Hook allows us to track state in a function component.
State generally refers to data or properties that need to be tracking in an application
When to Use useState
 We need a simple state management solution.
 We component has state that changes over time.
 The state does not require complex updates or dependencies.
[Hook] useState Understading Inside
25
[Hook] useState Understading Inside
State
Holds all data
view
26
[Hook] useState Understading Inside
27
[Hook] useState Understading Inside
[Hook] useState Working With Immutable Object
28
Immutability : state can’t modify or mutate directly , but
previous object can be change by creating and replacing by new
object
React can’t track prevoius state if you change the state directly
React can’t re-render the component if you change the state directly
29
[Hook] useState Working With Immutable Object
27
[Hook] useState Working With Immutable Object
31
[Hook] useState Working With Immutable Array
 don't modify or mutate directly
 Make new copy using spread (...) operator
 use setState process for update
32
[Hook] useState Working With Immutable Array
33
useState Spread Operator And Immutability Principle
Main
Object/Origi
nal DOM
Clone Object
1/Virtual
DOM1
Clone Object
3/Virtual
DOM3
Clone Object
2/Virtual DOM2
diffting
Reconciliation
34
[Hook] useState Working With Immutable Array
 The spread operator (...) in React.js is a powerful feature that simplifies working with
arrays and objects, particularly when managing component state.
 Used to expand the iterable items , The three dots syntax (...) is used
 spread operator (...) is used for cloning, merging, or passing props, arrays, or objects
in a concise and readable way to a component
 React state should be immutable . It allows you to create shallow copies of arrays and
objects, making it easier to update them without directly modifying the original data.
 It’s a JavaScript feature, not unique to React
35
[Hook] useState Working With Immutable Array
 The spread operator helps create new objects or arrays with the desired changes, leaving
the original data untouched.
 In React, it's crucial to maintain immutability of state.
 Directly modifying state can lead to unexpected behavior and hinder performance
optimizations.
Immutability:
36
[Hook] useEffect understanding arguments and uses
🔸 useEffect Has Two Arguments
1. Callback Function — () => { ... }
 This is the function that runs after the component renders.
 You perform your side effects here — like calling an API,
setting up intervals, adding event listeners, etc.
useEffect(() => {
console.log("Component mounted");
}, []);
📍 Only runs once, like componentDidMount.
37
[Hook] useEffect understanding arguments and uses
🔸 useEffect Has Two Arguments
2. Dependency Array — [dep1, dep2, ...] (optional)
 This array tells React when to run the effect.
 React compares the current values with the previous ones
 If any dependency has changed, the effect runs again.
 If the array is empty ([]), the effect runs only once on mount.
 If you omit the array, the effect runs after every render.
useEffect(() => {
console.log("Count changed:");
}, [1]);
📍 Runs every time count changes.
useEffect : perform side effects in function components, like data fetching,
subscriptions, DOM manipulation, etc.
38
[Hook] useEffect understanding arguments and uses
38
[Hook] useEffect understanding arguments and uses promises style
Api Call
Do’t go next step
If previous step fails
38
[Hook] useEffect understanding arguments and uses , async await process
Api Call
Do’t go next step
If previous step fails

More Related Content

PPTX
React.js - The Dawn of Virtual DOM
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PDF
Tech Talk on ReactJS
PPTX
React Workshop: Core concepts of react
PDF
An Intense Overview of the React Ecosystem
PPTX
ReactJS Code Impact
PPTX
React_Complete.pptx
PPTX
2.React tttttttttttttttttttttttttttttttt
React.js - The Dawn of Virtual DOM
Reactjs notes.pptx for web development- tutorial and theory
Tech Talk on ReactJS
React Workshop: Core concepts of react
An Intense Overview of the React Ecosystem
ReactJS Code Impact
React_Complete.pptx
2.React tttttttttttttttttttttttttttttttt

Similar to component-based JavaScript library in react.pptx (20)

PPTX
React workshop
PPTX
reactJS
PDF
a-detailed-guide-everything-you-need-to-know-about-reactjs.pdf
PPTX
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
PDF
react hook and wesite making structure ppt
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
PDF
Learning React js Learn React JS From Scratch with Hands On Projects 2nd Edit...
PPTX
How to react: Chapter 1, The Beginning
PPTX
react js training|react js training in mumbai|
PDF
FRONTEND DEVELOPMENT WITH REACT.JS
PPTX
React js
PDF
React js
PPTX
Dyanaimcs of business and economics unit 2
PPSX
REACTJS1.ppsx
PPTX
ReactJS - Re-rendering pages in the age of the mutable DOM
PDF
Fundamental concepts of react js
PDF
React JS Interview Questions PDF By ScholarHat
PPTX
This Is the ppt of How the react js work in the dealy life
PPTX
Comprehensive Analysis of React concept.pptx
PPTX
reacts js with basic details Detailed_ReactJS_Presentation.pptx
React workshop
reactJS
a-detailed-guide-everything-you-need-to-know-about-reactjs.pdf
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
react hook and wesite making structure ppt
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Learning React js Learn React JS From Scratch with Hands On Projects 2nd Edit...
How to react: Chapter 1, The Beginning
react js training|react js training in mumbai|
FRONTEND DEVELOPMENT WITH REACT.JS
React js
React js
Dyanaimcs of business and economics unit 2
REACTJS1.ppsx
ReactJS - Re-rendering pages in the age of the mutable DOM
Fundamental concepts of react js
React JS Interview Questions PDF By ScholarHat
This Is the ppt of How the react js work in the dealy life
Comprehensive Analysis of React concept.pptx
reacts js with basic details Detailed_ReactJS_Presentation.pptx
Ad

Recently uploaded (20)

PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
PPT on Performance Review to get promotions
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PPT
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PPTX
UNIT - 3 Total quality Management .pptx
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
Current and future trends in Computer Vision.pptx
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPT on Performance Review to get promotions
Visual Aids for Exploratory Data Analysis.pdf
Fundamentals of Mechanical Engineering.pptx
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
R24 SURVEYING LAB MANUAL for civil enggi
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
UNIT - 3 Total quality Management .pptx
Information Storage and Retrieval Techniques Unit III
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
UNIT 4 Total Quality Management .pptx
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
86236642-Electric-Loco-Shed.pdf jfkduklg
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Current and future trends in Computer Vision.pptx
Ad

component-based JavaScript library in react.pptx

  • 1. React JS ReactJS is a component-based JavaScript library used to build dynamic and interactive user interfaces. 01
  • 2. React JS 02 It simplifies the creation of single-page applications (SPAs) with a focus on performance and maintainability.  It is developed and by Facebook & now maintained by community developer.  Uses a virtual DOM for faster updates.  Supports a declarative approach to designing UI components.  Ensures better application control with one-way data binding.
  • 3. What is react component ? 03  components are the building blocks of a React application  A component is essentially a reusable, self-contained piece of UI.  React allows you to break down a complex UI into smaller, manageable pieces  React offers two main types of components: functional components and class components.
  • 5. First react project using vite 05  Vite is a modern frontend build tool that provides a faster development experience & development server experience for modern web projects . npm create vite@latest
  • 7. Why vite ? 07  Vite is a fast, modern build tool with Hot Module Replacement features created by the founder of Vue.js Evan You ,  designed for optimized development and production workflows. Top Reasons to Use Vite ⚡ 1. Ultra-Fast Development Server  ite uses native ES modules to serve files directly to the browser.
  • 8. Why vite ? 08  No bundling during development = instant startup.  Changes in code are reflected almost instantly with Hot Module Replacement (HMR). ⚡ 1. Uses Rollup under the hood for efficient bundling.  Automatically splits code, removes unused code (tree-shaking), and minifies output. 📦 2. Optimized Production Build
  • 9. Why vite ? 09 🚀 3. Out-of-the-Box Modern Features  ES6+ support, TypeScript, JSX, CSS modules, PostCSS, and more — no extra config needed.  Built-in support for .env files, dynamic imports, and asset handling. 🎯 4. Minimal Config & Easy Setup  Create a working project in seconds using: npm create vite@latest
  • 10. Why vite ? 10 💡 5. Great DX (Developer Experience)  Cleaner error messages.  Fast feedback loop = higher productivity.  Plugins and integrations are simpler. 🧩 6. Framework Agnostic, But Optimized  Works great with Vue 3, React, Svelte, Lit, Solid, and even plain JavaScript.  Official templates for each framework.
  • 11. Why vite ? 11 🔄 7. Fast Refresh & HMR  When you save a file, only the module that changed is updated in the browser.  This leads to a smoother and faster dev workflow compared to traditional bundlers. 🌍 8. Strong Community & Ecosystem  Backed by Evan You (Vue’s creator).  Active plugin ecosystem.  Popular among frontend frameworks and open source tools.
  • 12. Run React Project 12 npm run dev npx vite OR For build npm run build npx vite build OR
  • 13. vite.config.js 13 npm run dev npx vite OR For build npm run build npx vite build OR
  • 14. React Project Structure 14 Distribution Node Modules Public Src main.jsx node_modules .gitignore App.jsx
  • 15. useRef Hook 15 built-in React Hook that returns a mutable reference object (ref) that persists across renders Accessing and manipulating DOM elements without triggering re-renders. Persisting values across renders without causing re-renders. Storing previous state values to compare changes between renders Optimizing performance by avoiding unnecessary state updates
  • 18. useRef Hook Working With Attribute 18
  • 19. useRef Working With Input Element 19
  • 20. [Hook] useRef Working With CSS Class 20
  • 21. [Hook] useRef Working With Persisted Mutable Property 21 The value of mutable property is only updated component is not re-rendered
  • 22. [Hook] useRef Caching Expensive Computation 22 useRef holds a persistent value that survives across renders but doesn’t cause re-renders when updated When can use it  When you need to re-use result multiple times without re-rendering  Cache expensive computations  Store previous values  Avoid recalculating something unnecessarily  Preventing reinitialization of complex objects Where can use it  For API Calling  Avoiding duplicate form submissions
  • 23. [Hook] useRef Caching Expensive Computation 23
  • 24. If state change occure then re-render the component 24 The React useState Hook allows us to track state in a function component. State generally refers to data or properties that need to be tracking in an application When to Use useState  We need a simple state management solution.  We component has state that changes over time.  The state does not require complex updates or dependencies. [Hook] useState Understading Inside
  • 25. 25 [Hook] useState Understading Inside State Holds all data view
  • 28. [Hook] useState Working With Immutable Object 28 Immutability : state can’t modify or mutate directly , but previous object can be change by creating and replacing by new object React can’t track prevoius state if you change the state directly React can’t re-render the component if you change the state directly
  • 29. 29 [Hook] useState Working With Immutable Object
  • 30. 27 [Hook] useState Working With Immutable Object
  • 31. 31 [Hook] useState Working With Immutable Array  don't modify or mutate directly  Make new copy using spread (...) operator  use setState process for update
  • 32. 32 [Hook] useState Working With Immutable Array
  • 33. 33 useState Spread Operator And Immutability Principle Main Object/Origi nal DOM Clone Object 1/Virtual DOM1 Clone Object 3/Virtual DOM3 Clone Object 2/Virtual DOM2 diffting Reconciliation
  • 34. 34 [Hook] useState Working With Immutable Array  The spread operator (...) in React.js is a powerful feature that simplifies working with arrays and objects, particularly when managing component state.  Used to expand the iterable items , The three dots syntax (...) is used  spread operator (...) is used for cloning, merging, or passing props, arrays, or objects in a concise and readable way to a component  React state should be immutable . It allows you to create shallow copies of arrays and objects, making it easier to update them without directly modifying the original data.  It’s a JavaScript feature, not unique to React
  • 35. 35 [Hook] useState Working With Immutable Array  The spread operator helps create new objects or arrays with the desired changes, leaving the original data untouched.  In React, it's crucial to maintain immutability of state.  Directly modifying state can lead to unexpected behavior and hinder performance optimizations. Immutability:
  • 36. 36 [Hook] useEffect understanding arguments and uses 🔸 useEffect Has Two Arguments 1. Callback Function — () => { ... }  This is the function that runs after the component renders.  You perform your side effects here — like calling an API, setting up intervals, adding event listeners, etc. useEffect(() => { console.log("Component mounted"); }, []); 📍 Only runs once, like componentDidMount.
  • 37. 37 [Hook] useEffect understanding arguments and uses 🔸 useEffect Has Two Arguments 2. Dependency Array — [dep1, dep2, ...] (optional)  This array tells React when to run the effect.  React compares the current values with the previous ones  If any dependency has changed, the effect runs again.  If the array is empty ([]), the effect runs only once on mount.  If you omit the array, the effect runs after every render. useEffect(() => { console.log("Count changed:"); }, [1]); 📍 Runs every time count changes. useEffect : perform side effects in function components, like data fetching, subscriptions, DOM manipulation, etc.
  • 38. 38 [Hook] useEffect understanding arguments and uses
  • 39. 38 [Hook] useEffect understanding arguments and uses promises style Api Call Do’t go next step If previous step fails
  • 40. 38 [Hook] useEffect understanding arguments and uses , async await process Api Call Do’t go next step If previous step fails