Core Concepts of
React
@imranhsayed
Imran Sayed
React Js
React is a javascript library for building
interactive User Interface( UI ).
2
3
Lorem Ipsum
Lorem IpsumLorem Ipsum
Lorem Ipsum Lorem Ipsum Lorem Ipsum
Lorem Ipsum Lorem Ipsum Lorem Ipsum
Root Element
<html>
Element
<body>
Element
<head>
Element
<title>
Element
<h1>
Element
<p>
Text Node
“Page title”
Text Node
“My heading”
Text Node
“My Paragraph
DOM
What makes React so
fast?
4
5
Virtual DOM
Virtual DOM
6
7
Virtual DOM
8
patch
Virtual DOM
9
Why is React fast?
10
Why is React so fast?
What is a
Virtual DOM?
A Javascript Object that is a
“virtual”, representation of the “real”
DOM.
11
Why use react?
● Updates and renders only the elements that
change/update in the DOM( hence quick rendering )
● Build encapsulated components that manage their own
state.
● React can also render on the server using Node and
powerful mobile apps using react native.
12
13
14
History of React
● Created by Jordan Walke, a software engineer at
Facebook
● First deployed on Facebook's newsfeed in 2011 and later
on Instagram.com in 2012
● Open-sourced at JSConf US in May 2013
● Facebook announced React Fiber, on April 18, 2017
● React 360 V1.0.0 was released to the public on April 19,
2017
15
1- Add React in a Minute (Using React Scripts )
2- Using create-react-app
Set up React App
16
Class Based Components
Extend React Component Class and
it requires us to use render()
React Components
Functional Based Components
Are pure JavaScript function that
accepts props as its argument, and
returns some JSX
17
Components allow you to split the UI into independent reusable pieces of
JS codes.
Class Based Components
Functional Based Components
18
JSX ( JavaScript-XML )
● JSX is a XML-like syntax extension to JavaScript that creates
React elements.
● Its makes your code human readable, otherwise we had to use
React.createElement()
● Gives us expressiveness of JavaScript along with HTML like
template syntax.
19
Examples of using JSX
20
What is a component
state?
● A State of a component is an object, that holds some
information that may change throughout the component
lifecycle.
21
State of a Component
22
Virtual DOM
State of a Component
23
Virtual DOM
State of a Component
24
Virtual DOM
State of a Component
25
Virtual DOM
setState()
State of a Component
26
Virtual DOM
setState()
State of a Component
27
Virtual DOM
setState()
State of a Component
28
setState()
patch
Virtual DOM
What is a component
state?
● A State of a component is an object, that holds some
information that may change throughout the component
lifecycle.
● We define initial state and then we just have to notify that the
state is changed and the react will automatically render the
those changes on the front end behind the scenes.
● Every time the state changes the changes get re rendered so
the UI( front end ) changes automatically.
29
Props
● Props are inputs to components.
● Single values or objects containing a set of values that are passed to
components on creation, using a naming convention similar to HTML-tag
attributes
● They are used to:
1-Pass custom data to your component.
2-Trigger state changes.
30
Important Points
● React may batch multiple setState() calls into a single update
for performance.
● Because this.props and this.state may be updated
asynchronously, you should not rely on their values for
calculating the next state
● State is local or encapsulated. It is not accessible to any
component other than the one that owns and sets it.
● A component may choose to pass its state down as props to
its child components
● Imagine a component tree as a waterfall of props, each
component’s state is like an additional water source that joins
it at an arbitrary point but also flows down
31
Difference between State & Props
Props
=Props is passed by the parent to the
Child components
-A component should never modify its
own props
Component State
=State is managed within a
component for internal
communication
- State can be modified using
setState() and when value of state
changes render() is called.
32
The props( properties ) and state are both JavaScript objects. Props are like an args
of a function and states are like local variables inside the function
Component LifeCycle
Mounting
- Component is constructed
with the given Props and
default state. This is done
inside constructor()
-Component came into the
DOM
Updating
- When the state of a
component is updated
33
Every React Component has a lifecycle of its own, which has different stages.
Unmounting
- Component is
removed from the
page
34
Constructor
● Overrides the constructor of React.Component
● Required only when we initialize state or bind methods.
E.g. this.handleClick = this.handleClick.bind(this);
● Call super(props) before any other statement.
● Do not call setState() inside it
35
getDerivedStateFromProp
s
● Invoked right before calling the render method
● Called both on the initial mount and on subsequent updates
● Should return an object to update the state, or null to update
nothing.
● Rare use cases where the state depends on changes in props
36
ComponentDidMount
● Load data from a remote endpoint
● Calling setState() here will trigger an extra rendering, but it will
happen before the browser updates the screen.
37
shouldComponentUpdate
● Exists as a performance optimization
● Not called for the initial render or when forceUpdate() is used.
● Use built-in PureComponent instead of writing
shouldComponentUpdate()
● PureComponent performs a shallow comparison of props and
state, and reduces the chance that you’ll skip a necessary
update.
38
render
● Required method in a class component
● Should return React Elements ( JSX ) or Arrays and fragments
or Portals or String and numbers or Booleans or null
● Should not modify component state
● It does not directly interact with the browser.
39
getSnapshotBeforeUpdat
e
● Invoked right before the most recently rendered output is
committed to e.g. the DOM
● Capture some information from the DOM (e.g. scroll position)
before it is potentially changed
● Returned value will be passed as a parameter to
componentDidUpdate()
● Example to use it: A chat thread that need to handle scroll
position in a special way.
40
ComponentDidUpdate
● Invoked immediately after updating occurs.
● Calling setState() here will trigger an extra rendering, but it will
happen before the browser updates the screen.
● setState() can be called but it must be wrapped in a condition.
● If getSnapshotBeforeUpdate() is implemented, snapshot
param will be available, else undefined.
41
ComponentWillUnmount
● invoked immediately before a component is unmounted.
● For e.g. Invalidating timers, canceling network requests, or
cleaning up any subscriptions.
● should not call setState() as component will never be
rerendered.
42
43
Thanks!
Any questions?
@imranhsayed
@imran_.sayed
youtube.com/c/ImranSayedDev

More Related Content

PPTX
React workshop
ODP
Introduction to ReactJS
PPTX
React-JS Component Life-cycle Methods
PPTX
Intro to React
PPTX
20180518 QNAP Seminar - Introduction to React Native
PPTX
React JS - A quick introduction tutorial
PDF
React – Structure Container Component In Meteor
PDF
React-js
React workshop
Introduction to ReactJS
React-JS Component Life-cycle Methods
Intro to React
20180518 QNAP Seminar - Introduction to React Native
React JS - A quick introduction tutorial
React – Structure Container Component In Meteor
React-js

What's hot (20)

PPTX
Introduction to React JS for beginners | Namespace IT
PPTX
React js - The Core Concepts
PPTX
[Final] ReactJS presentation
PDF
React js
PPTX
React JS: A Secret Preview
PPTX
React js Rahil Memon
PPTX
Introduction to React
PPTX
React js programming concept
PPTX
ReactJs
PPTX
React and Flux life cycle with JSX, React Router and Jest Unit Testing
PPTX
Reactjs
PPTX
PPTX
React js for beginners
PDF
Using Dagger in a Clean Architecture project
PPTX
React workshop presentation
PPTX
Its time to React.js
PPT
React js
PPTX
reactJS
PDF
React js use contexts and useContext hook
PPTX
Introduction to React JS
Introduction to React JS for beginners | Namespace IT
React js - The Core Concepts
[Final] ReactJS presentation
React js
React JS: A Secret Preview
React js Rahil Memon
Introduction to React
React js programming concept
ReactJs
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Reactjs
React js for beginners
Using Dagger in a Clean Architecture project
React workshop presentation
Its time to React.js
React js
reactJS
React js use contexts and useContext hook
Introduction to React JS
Ad

Similar to React Workshop: Core concepts of react (20)

PPTX
2.React tttttttttttttttttttttttttttttttt
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
PPTX
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
PPTX
Dyanaimcs of business and economics unit 2
PDF
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
PPTX
Getting started with react &amp; redux
PPTX
Presentation on "An Introduction to ReactJS"
PPTX
ReactJS (1)
PDF
React Interview Question & Answers PDF By ScholarHat
PDF
ReactJS for Programmers
PPTX
PDF
ReactJS - A quick introduction to Awesomeness
PDF
REACTJS.pdf
PDF
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
PPTX
PDF
react hook and wesite making structure ppt
PDF
Introduction Web Development using ReactJS
PPTX
ReactJS presentation.pptx
PPTX
React.js - The Dawn of Virtual DOM
PPTX
React - Start learning today
2.React tttttttttttttttttttttttttttttttt
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
Dyanaimcs of business and economics unit 2
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
Getting started with react &amp; redux
Presentation on "An Introduction to ReactJS"
ReactJS (1)
React Interview Question & Answers PDF By ScholarHat
ReactJS for Programmers
ReactJS - A quick introduction to Awesomeness
REACTJS.pdf
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
react hook and wesite making structure ppt
Introduction Web Development using ReactJS
ReactJS presentation.pptx
React.js - The Dawn of Virtual DOM
React - Start learning today
Ad

More from Imran Sayed (20)

PPTX
Docker with WordPress
PPTX
Why Progressive Web Apps For WordPress - WordCamp Finland
PPTX
Custom gutenberg block development in react
PPTX
Fastest Way of Creating Gutenberg Blocks - WordCamp Rochester
PPTX
Harness The Power Of ACF For Gatsby and WordPress
PPTX
Improving Your Debugging Skills In WordPress
PPTX
Build Modern Web Applications with React and WordPress
PPTX
Why progressive apps for WordPress - WordSesh 2020
PPTX
Digging Into Gutenberg
PPTX
Fastest Way Of Creating Gutenberg Blocks With Minimal JavaScript Knowledge ...
PDF
Why progressive web apps for word press wc-ahemdabad
PPTX
Build fast word press site in react in 30 mins with frontity
PPTX
Build Fast WordPress Site With Gatsby
PPTX
Why Progressive Apps For WordPress?
PPTX
Creating Gutenberg Blocks With ACF
PPTX
Custom gutenberg block development with React
PPTX
SSR with React - Connecting Next.js with WordPress
PDF
React with WordPress : Headless CMS
PPTX
Redux workshop
PPTX
Introduction to Gutenberg- Imran Sayed
Docker with WordPress
Why Progressive Web Apps For WordPress - WordCamp Finland
Custom gutenberg block development in react
Fastest Way of Creating Gutenberg Blocks - WordCamp Rochester
Harness The Power Of ACF For Gatsby and WordPress
Improving Your Debugging Skills In WordPress
Build Modern Web Applications with React and WordPress
Why progressive apps for WordPress - WordSesh 2020
Digging Into Gutenberg
Fastest Way Of Creating Gutenberg Blocks With Minimal JavaScript Knowledge ...
Why progressive web apps for word press wc-ahemdabad
Build fast word press site in react in 30 mins with frontity
Build Fast WordPress Site With Gatsby
Why Progressive Apps For WordPress?
Creating Gutenberg Blocks With ACF
Custom gutenberg block development with React
SSR with React - Connecting Next.js with WordPress
React with WordPress : Headless CMS
Redux workshop
Introduction to Gutenberg- Imran Sayed

Recently uploaded (20)

PDF
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
PPTX
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PDF
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
PPT
3.Software Design for software engineering
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
PDF
Mobile App Backend Development with WordPress REST API: The Complete eBook
PPTX
SAP Business AI_L1 Overview_EXTERNAL.pptx
PDF
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
PPTX
Lesson-3-Operation-System-Support.pptx-I
PPTX
Human Computer Interaction lecture Chapter 2.pptx
PPTX
Why 2025 Is the Best Year to Hire Software Developers in India
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PDF
infoteam HELLAS company profile 2025 presentation
PDF
Mobile App for Guard Tour and Reporting.pdf
PPTX
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
PPTX
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PDF
solman-7.0-ehp1-sp21-incident-management
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
HackYourBrain__UtrechtJUG__11092025.pptx
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
3.Software Design for software engineering
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Mobile App Backend Development with WordPress REST API: The Complete eBook
SAP Business AI_L1 Overview_EXTERNAL.pptx
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
Lesson-3-Operation-System-Support.pptx-I
Human Computer Interaction lecture Chapter 2.pptx
Why 2025 Is the Best Year to Hire Software Developers in India
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
infoteam HELLAS company profile 2025 presentation
Mobile App for Guard Tour and Reporting.pdf
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
solman-7.0-ehp1-sp21-incident-management

React Workshop: Core concepts of react

  • 2. React Js React is a javascript library for building interactive User Interface( UI ). 2
  • 3. 3 Lorem Ipsum Lorem IpsumLorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Root Element <html> Element <body> Element <head> Element <title> Element <h1> Element <p> Text Node “Page title” Text Node “My heading” Text Node “My Paragraph DOM
  • 4. What makes React so fast? 4
  • 10. 10 Why is React so fast?
  • 11. What is a Virtual DOM? A Javascript Object that is a “virtual”, representation of the “real” DOM. 11
  • 12. Why use react? ● Updates and renders only the elements that change/update in the DOM( hence quick rendering ) ● Build encapsulated components that manage their own state. ● React can also render on the server using Node and powerful mobile apps using react native. 12
  • 13. 13
  • 14. 14
  • 15. History of React ● Created by Jordan Walke, a software engineer at Facebook ● First deployed on Facebook's newsfeed in 2011 and later on Instagram.com in 2012 ● Open-sourced at JSConf US in May 2013 ● Facebook announced React Fiber, on April 18, 2017 ● React 360 V1.0.0 was released to the public on April 19, 2017 15
  • 16. 1- Add React in a Minute (Using React Scripts ) 2- Using create-react-app Set up React App 16
  • 17. Class Based Components Extend React Component Class and it requires us to use render() React Components Functional Based Components Are pure JavaScript function that accepts props as its argument, and returns some JSX 17 Components allow you to split the UI into independent reusable pieces of JS codes.
  • 18. Class Based Components Functional Based Components 18
  • 19. JSX ( JavaScript-XML ) ● JSX is a XML-like syntax extension to JavaScript that creates React elements. ● Its makes your code human readable, otherwise we had to use React.createElement() ● Gives us expressiveness of JavaScript along with HTML like template syntax. 19
  • 21. What is a component state? ● A State of a component is an object, that holds some information that may change throughout the component lifecycle. 21
  • 22. State of a Component 22 Virtual DOM
  • 23. State of a Component 23 Virtual DOM
  • 24. State of a Component 24 Virtual DOM
  • 25. State of a Component 25 Virtual DOM setState()
  • 26. State of a Component 26 Virtual DOM setState()
  • 27. State of a Component 27 Virtual DOM setState()
  • 28. State of a Component 28 setState() patch Virtual DOM
  • 29. What is a component state? ● A State of a component is an object, that holds some information that may change throughout the component lifecycle. ● We define initial state and then we just have to notify that the state is changed and the react will automatically render the those changes on the front end behind the scenes. ● Every time the state changes the changes get re rendered so the UI( front end ) changes automatically. 29
  • 30. Props ● Props are inputs to components. ● Single values or objects containing a set of values that are passed to components on creation, using a naming convention similar to HTML-tag attributes ● They are used to: 1-Pass custom data to your component. 2-Trigger state changes. 30
  • 31. Important Points ● React may batch multiple setState() calls into a single update for performance. ● Because this.props and this.state may be updated asynchronously, you should not rely on their values for calculating the next state ● State is local or encapsulated. It is not accessible to any component other than the one that owns and sets it. ● A component may choose to pass its state down as props to its child components ● Imagine a component tree as a waterfall of props, each component’s state is like an additional water source that joins it at an arbitrary point but also flows down 31
  • 32. Difference between State & Props Props =Props is passed by the parent to the Child components -A component should never modify its own props Component State =State is managed within a component for internal communication - State can be modified using setState() and when value of state changes render() is called. 32 The props( properties ) and state are both JavaScript objects. Props are like an args of a function and states are like local variables inside the function
  • 33. Component LifeCycle Mounting - Component is constructed with the given Props and default state. This is done inside constructor() -Component came into the DOM Updating - When the state of a component is updated 33 Every React Component has a lifecycle of its own, which has different stages. Unmounting - Component is removed from the page
  • 34. 34
  • 35. Constructor ● Overrides the constructor of React.Component ● Required only when we initialize state or bind methods. E.g. this.handleClick = this.handleClick.bind(this); ● Call super(props) before any other statement. ● Do not call setState() inside it 35
  • 36. getDerivedStateFromProp s ● Invoked right before calling the render method ● Called both on the initial mount and on subsequent updates ● Should return an object to update the state, or null to update nothing. ● Rare use cases where the state depends on changes in props 36
  • 37. ComponentDidMount ● Load data from a remote endpoint ● Calling setState() here will trigger an extra rendering, but it will happen before the browser updates the screen. 37
  • 38. shouldComponentUpdate ● Exists as a performance optimization ● Not called for the initial render or when forceUpdate() is used. ● Use built-in PureComponent instead of writing shouldComponentUpdate() ● PureComponent performs a shallow comparison of props and state, and reduces the chance that you’ll skip a necessary update. 38
  • 39. render ● Required method in a class component ● Should return React Elements ( JSX ) or Arrays and fragments or Portals or String and numbers or Booleans or null ● Should not modify component state ● It does not directly interact with the browser. 39
  • 40. getSnapshotBeforeUpdat e ● Invoked right before the most recently rendered output is committed to e.g. the DOM ● Capture some information from the DOM (e.g. scroll position) before it is potentially changed ● Returned value will be passed as a parameter to componentDidUpdate() ● Example to use it: A chat thread that need to handle scroll position in a special way. 40
  • 41. ComponentDidUpdate ● Invoked immediately after updating occurs. ● Calling setState() here will trigger an extra rendering, but it will happen before the browser updates the screen. ● setState() can be called but it must be wrapped in a condition. ● If getSnapshotBeforeUpdate() is implemented, snapshot param will be available, else undefined. 41
  • 42. ComponentWillUnmount ● invoked immediately before a component is unmounted. ● For e.g. Invalidating timers, canceling network requests, or cleaning up any subscriptions. ● should not call setState() as component will never be rerendered. 42