SlideShare a Scribd company logo
1 of 25
React
The Dawn of Virtual DOM
What is React
A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES
Main Features
• Just V of MVC
• Virtual DOM
• One Way Data Flow
Background of React
• Started by Facebook in 2013
• Motivation - building large applications with data that
changes over time.
• Over 40k+ Star on Github and 645 contributors
• You are in a good company
Source - https://github.com/facebook/react/wiki/Sites-Using-React
Lets Get started
The most important thing
Virtual DOM
To understand this We need to first see
Real DOM
The Reason for performance
Real DOM
Disadvantage
DOM manipulation APIs are slow
Surprisingly 😟
All the framework do this on every update
Enter the Dawn of Virtual DOM
React DOM Update Strategy
React’s Virtual DOM Strategy
On every update to component
• React Builds New Virtual DOM Subtree
• Diff with the actual DOM
• Computes minimal DOM mutation
• Batch executes updates
Benefits
Minimal DOM manipulation calls
Batch execution saves a lot of computation
Super Fast Performance
Getting started with React
React Terminology
React Elements
(Basic Building Block)
var root = React.createElement('div');
React.js Main React Library
react-dom.js
Supporting library to generate DOM
notation
Factories
(Called internally by React Element)
function createFactory(type) {
return React.createElement.bind(null, type);
}
React Nodes Tree of React Element
React Components
var MyComponent = React.createClass({
render: function() {
...
}
});
(Encapsulated React Elements)
(You will use this the most)
React Recommends Use of JSX
What is JSX
ped, object-oriented programming language designed to run on m
In short
Its just like Type script and transpiles into Plain Javascript
Without JSX
With JSX
Recommended Build Tool
Webpack
• Bundles JS using require.js
• Minification, Linting, Production Build
• Loaders system allows easy
extensibility
• Just like gulp but more powerful
• Lets us use ES6 and ES7 features
• React tags are transformed
automatically using babel-react-
presets module
Demo Time
Props
• Props are like parameter to functions
• They make component super re-usable
• Way to pass info from one component to other component
• Includes props type validation to ensure sanity of data
Demo
STATE
• Holds the current state of the component
• Update in the state variable updates the component
• getInitialState and setState method for updating state
value
Demo
Refs
• Used to keep reference to components
• If callback function is passed, then callback is executed just
after the component mounts with component as parameter
• Possible application includes animation, finding specific
node
Component Specification
• render -> Required method. Returns ReactElement
• getInitialState -> Not Required, If we require some
default state for component
• getDefaultProps -> Not Required. If we want to set
default value of prop.
• propTypes -> Not Required. Allows the prop type
validation
Demo
Component Lifecycle
• componentWillMount -> Invoked before the initial rendering of component
• componentWillReceiveProps -> Invoked before the component receives the props
(not on initial render)
• componentDidUpdate -> Invoked immediately after the update of comports are
flushed to DOM
• componentDidMount -> Invoked after initial rendering of the component (Used
for fetching data from server)
• componentWillUpdate -> Called before rendering.
• shouldComponentUpdate -> Must return true (or) false. Called when new state (or)
props are being received.
• componentWillUnmount -> Called before component is unmounted
Advantages
Declarative Nature
numbers = [1,2,3,4]
total = 0
for(i=0; i<numbers.length; i++)
{
total = total + numbers[i]
}
Implicit Declarative
numbers = [1,2,3,4]
numbers.reduce(
function(previousValue, currentValue) {
return previousValue + currentValue;
});
• componentWillMount()
• componentWillReceiveProps( {NextProps} )
• componentDidUpdate( {PreviousProps} , {PreviousState} )
• componentDidMount()
• componentWillUnmount()
• getInitialState
Example
Advantages
Composition
• Rather than building one big component, React
allows to focus building mini components to
compose one big component out of it.
• Highly reusable code
Synthetic events
• Only single event listener is binded per component
• Results in less memory usage and improvement in perform
Plain Javascript
• Directive
• digest cycle
• Transclude function
• $scope and $rootScope
• $scope.$apply
We have all suffered our way through
Not anymore
React is pure javascript
Less time learning and more time implementing
Best in class dev tool
react-devtools
Growing Eco system
React-router Axios - Promise library
Redux
React-Desktop React-Native
react-material
Source - https://github.com/enaqx/awesome-react#components
countless more …….
React-select
Thank You

More Related Content

What's hot (20)

Intro to React
Intro to ReactIntro to React
Intro to React
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Reactjs
Reactjs Reactjs
Reactjs
 
ReactJS
ReactJSReactJS
ReactJS
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
React js
React jsReact js
React js
 
React workshop
React workshopReact workshop
React workshop
 
React js
React jsReact js
React js
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
ReactJS
ReactJSReactJS
ReactJS
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 

Viewers also liked

Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOMDaiwei Lu
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesomeAndrew Hull
 
React for .net developers
React for .net developersReact for .net developers
React for .net developersmacsdickinson
 
CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)Chih-cheng Wang
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Editionbensmithett
 
Javascript template & react js 初探
Javascript template & react js 初探Javascript template & react js 初探
Javascript template & react js 初探wantingj
 
Synchronizing application state using Virtual DOM trees
Synchronizing application state using Virtual DOM treesSynchronizing application state using Virtual DOM trees
Synchronizing application state using Virtual DOM treesJari Voutilainen
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactYos Riady
 
Intro to Web Map APIs
Intro to Web Map APIsIntro to Web Map APIs
Intro to Web Map APIsYos Riady
 
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina University of Helsinki
 
ReactNativeを語る勉強会
ReactNativeを語る勉強会ReactNativeを語る勉強会
ReactNativeを語る勉強会yohei sugigami
 
From Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyFrom Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyKhor SoonHin
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsGrgur Grisogono
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - WorkshopFellipe Chagas
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSHoang Long
 

Viewers also liked (20)

Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
 
React for .net developers
React for .net developersReact for .net developers
React for .net developers
 
CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
 
Javascript template & react js 初探
Javascript template & react js 初探Javascript template & react js 初探
Javascript template & react js 初探
 
React entry
React entryReact entry
React entry
 
Synchronizing application state using Virtual DOM trees
Synchronizing application state using Virtual DOM treesSynchronizing application state using Virtual DOM trees
Synchronizing application state using Virtual DOM trees
 
Repaint & reflow
Repaint & reflowRepaint & reflow
Repaint & reflow
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
Intro to Web Map APIs
Intro to Web Map APIsIntro to Web Map APIs
Intro to Web Map APIs
 
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
ReactNativeを語る勉強会
ReactNativeを語る勉強会ReactNativeを語る勉強会
ReactNativeを語る勉強会
 
Pjax 深入淺出
Pjax 深入淺出Pjax 深入淺出
Pjax 深入淺出
 
React
ReactReact
React
 
From Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyFrom Back to Front: Rails To React Family
From Back to Front: Rails To React Family
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - Workshop
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 

Similar to React.js - The Dawn of Virtual DOM

React and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit TestingEswara Kumar Palakollu
 
Optimizing your use of react life cycles by shedrack akintayo
Optimizing your use of react life cycles by shedrack akintayoOptimizing your use of react life cycles by shedrack akintayo
Optimizing your use of react life cycles by shedrack akintayoShedrack Akintayo
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.jsFederico Torre
 
Continuous Integration on AWS
Continuous Integration on AWSContinuous Integration on AWS
Continuous Integration on AWSPetar Petrov
 
Introduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic AppsIntroduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic AppsFederico Torre
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobXDarko Kukovec
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Building High-Performance Force.com Applications in React
Building High-Performance Force.com Applications in ReactBuilding High-Performance Force.com Applications in React
Building High-Performance Force.com Applications in ReactSalesforce Developers
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactAustin Garrod
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshopStacy Goh
 
Bundle deployment at state machine level - Ales Justin, JBoss
Bundle deployment at state machine level - Ales Justin, JBossBundle deployment at state machine level - Ales Justin, JBoss
Bundle deployment at state machine level - Ales Justin, JBossmfrancis
 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React BasicsRich Ross
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React nativeDhaval Barot
 

Similar to React.js - The Dawn of Virtual DOM (20)

React and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit Testing
 
Optimizing your use of react life cycles by shedrack akintayo
Optimizing your use of react life cycles by shedrack akintayoOptimizing your use of react life cycles by shedrack akintayo
Optimizing your use of react life cycles by shedrack akintayo
 
React Native Firebase
React Native FirebaseReact Native Firebase
React Native Firebase
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.js
 
Continuous Integration on AWS
Continuous Integration on AWSContinuous Integration on AWS
Continuous Integration on AWS
 
Introduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic AppsIntroduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic Apps
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobX
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Building High-Performance Force.com Applications in React
Building High-Performance Force.com Applications in ReactBuilding High-Performance Force.com Applications in React
Building High-Performance Force.com Applications in React
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshop
 
Bundle deployment at state machine level - Ales Justin, JBoss
Bundle deployment at state machine level - Ales Justin, JBossBundle deployment at state machine level - Ales Justin, JBoss
Bundle deployment at state machine level - Ales Justin, JBoss
 
React JS
React JSReact JS
React JS
 
ReactJS
ReactJSReactJS
ReactJS
 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React Basics
 
React.js+Redux Workshops
React.js+Redux WorkshopsReact.js+Redux Workshops
React.js+Redux Workshops
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
 

Recently uploaded

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 

Recently uploaded (20)

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 

React.js - The Dawn of Virtual DOM

  • 1. React The Dawn of Virtual DOM
  • 2. What is React A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES Main Features • Just V of MVC • Virtual DOM • One Way Data Flow
  • 3. Background of React • Started by Facebook in 2013 • Motivation - building large applications with data that changes over time. • Over 40k+ Star on Github and 645 contributors • You are in a good company Source - https://github.com/facebook/react/wiki/Sites-Using-React
  • 4. Lets Get started The most important thing Virtual DOM To understand this We need to first see Real DOM The Reason for performance
  • 5. Real DOM Disadvantage DOM manipulation APIs are slow Surprisingly 😟 All the framework do this on every update
  • 6. Enter the Dawn of Virtual DOM React DOM Update Strategy
  • 7. React’s Virtual DOM Strategy On every update to component • React Builds New Virtual DOM Subtree • Diff with the actual DOM • Computes minimal DOM mutation • Batch executes updates
  • 8. Benefits Minimal DOM manipulation calls Batch execution saves a lot of computation Super Fast Performance
  • 9.
  • 10. Getting started with React React Terminology React Elements (Basic Building Block) var root = React.createElement('div'); React.js Main React Library react-dom.js Supporting library to generate DOM notation Factories (Called internally by React Element) function createFactory(type) { return React.createElement.bind(null, type); } React Nodes Tree of React Element React Components var MyComponent = React.createClass({ render: function() { ... } }); (Encapsulated React Elements) (You will use this the most)
  • 11. React Recommends Use of JSX What is JSX ped, object-oriented programming language designed to run on m In short Its just like Type script and transpiles into Plain Javascript Without JSX With JSX
  • 12. Recommended Build Tool Webpack • Bundles JS using require.js • Minification, Linting, Production Build • Loaders system allows easy extensibility • Just like gulp but more powerful • Lets us use ES6 and ES7 features • React tags are transformed automatically using babel-react- presets module
  • 14. Props • Props are like parameter to functions • They make component super re-usable • Way to pass info from one component to other component • Includes props type validation to ensure sanity of data Demo
  • 15. STATE • Holds the current state of the component • Update in the state variable updates the component • getInitialState and setState method for updating state value Demo
  • 16. Refs • Used to keep reference to components • If callback function is passed, then callback is executed just after the component mounts with component as parameter • Possible application includes animation, finding specific node
  • 17. Component Specification • render -> Required method. Returns ReactElement • getInitialState -> Not Required, If we require some default state for component • getDefaultProps -> Not Required. If we want to set default value of prop. • propTypes -> Not Required. Allows the prop type validation Demo
  • 18. Component Lifecycle • componentWillMount -> Invoked before the initial rendering of component • componentWillReceiveProps -> Invoked before the component receives the props (not on initial render) • componentDidUpdate -> Invoked immediately after the update of comports are flushed to DOM • componentDidMount -> Invoked after initial rendering of the component (Used for fetching data from server) • componentWillUpdate -> Called before rendering. • shouldComponentUpdate -> Must return true (or) false. Called when new state (or) props are being received. • componentWillUnmount -> Called before component is unmounted
  • 19. Advantages Declarative Nature numbers = [1,2,3,4] total = 0 for(i=0; i<numbers.length; i++) { total = total + numbers[i] } Implicit Declarative numbers = [1,2,3,4] numbers.reduce( function(previousValue, currentValue) { return previousValue + currentValue; }); • componentWillMount() • componentWillReceiveProps( {NextProps} ) • componentDidUpdate( {PreviousProps} , {PreviousState} ) • componentDidMount() • componentWillUnmount() • getInitialState Example
  • 20. Advantages Composition • Rather than building one big component, React allows to focus building mini components to compose one big component out of it. • Highly reusable code
  • 21. Synthetic events • Only single event listener is binded per component • Results in less memory usage and improvement in perform
  • 22. Plain Javascript • Directive • digest cycle • Transclude function • $scope and $rootScope • $scope.$apply We have all suffered our way through Not anymore React is pure javascript Less time learning and more time implementing
  • 23. Best in class dev tool react-devtools
  • 24. Growing Eco system React-router Axios - Promise library Redux React-Desktop React-Native react-material Source - https://github.com/enaqx/awesome-react#components countless more ……. React-select