SlideShare a Scribd company logo
1
Comparing React and
Angular
Discussion Agenda
• React and Angular Tool Overview
• Side-By-Side Comparison
• Sample Code
• Architectural Comparisons:
• Component Tree Architecture
• Angular Digest Cycle
• React Virtual DOM
• Data Binding
• Big Picture Comparison
2
Overview
3
Angular is a Framework for
building Web Applications.
React is a JavaScript Library
for building User Interfaces.
Overview
4
Different problems are often best solved using different
tools. We will be discussing the features of React and
Angular and how they are both best suited for building
different types of Single Page Applications.
Overview – Developer Interest
5
Interestingly, in the 2017 Stack Overflow survey, React is
the most loved technology, while AngularJS is the most
used web development technology.
In general, developers tend to enjoy working with React
very much, while architectural decisions tend to be made
favoring Angular.
https://insights.stackoverflow.com/survey/2017#technology
Overview - Angular
6
• TypeScript-based open-source front-end web
application platform for building single page
applications.
• Uses component based architecture.
• Creates components by grouping structure and
function into HTML templates.
• Developers use components to build apps
declaratively.
• Provides simple framework solutions for
foundational functionality (routing, HTTP, forms,
etc) which can be customized.
• Digest cycle re-renders entire view when
data is updated.
• Functionality is organized into modules which
are loaded dynamically.
• Angular apps are loosely MVC, MVW, etc.
• Angular apps need to be built
Overview – React
7
• JavaScript library for building user interfaces.
• Uses components to build UIs.
• React components manage their own internal
state
• Components are written in JavaScript and JSX
• Only contains library functions for building views
• Builds views from encapsulated components
so UI only updates necessary elements when
data changes.
• All components contain structure by
implementing render() function which returns
HTML.
• React library is light, and needs outside tools to
serve, reuse components, etc.
• Standard tools exist, however (ex. create-react-
app
• React Uis also need to be built.
Side-By-Side Comparison of Angular and React - Stats
8
Side-By-Side Comparison of Angular and React - Features
9
Sample Code
<form (ngSubmit)="onSubmit(heroForm)"
#heroForm="ngForm">
<div class="form-group">
<label for="name">Name
<input class="form-control" name="name"
required [(ngModel)]="hero.name">
</label>
</div>
<button type="submit"
[disabled]="!heroForm.form.valid">Submit</b
utton>
</form>
<div [hidden]="!heroForm.form.valid">
{{submitMessage}}
</div>
10
var Saves = React.createClass({
getInitialState: function(){
…..
},
handleSubmit: function(e) {
…
},
render: function() {
var savedText = '';
var submitText = 'Save';
if (this.state.saved) {
savedText = 'You have saved this home.';
submitText = 'Remove';
}
return (
<div className="saves">
<form onSubmit={this.handleSubmit}>
<input type="submit" value={submitText} />
</form>
{this.state.numSaves} saves. {savedText}
</div>
);
}
});
JavaScript in HTML!
JS Render function
contains HTML!
Angular Template React JS Class
Review: Component Based Architecture
• Components are UI elements
which encapsulate functionality
and structure.
• Components are custom HTML
elements which contain HTML
coupled with functionality defined
in JavaScript.
• Components also contain an
isolated data scope. React
components use their isolated
scope to independently update the
view when bound data changes.
• The DOM is a tree of
components. There is a root
component and child components
as in the basic DOM.
11
How Angular Renders Components
• Angular components exist in TypeScript Component files and their corresponding
HTML template files.
• Angular renders a view by loading the base component (defined in the base module)
in TypeScript code and rendering the resulting tree of components.
• When Angular renders a component, it loads the component TypeScript code into
memory, then renders the resulting augmented HTML into the browser by parsing
the HTML template file and adding functionality (events, bound data, etc) from the
component code.
• When data bound to the view changes, the framework Digest Cycle is triggered to
refresh the rendered view.
• The Digest Cycle checks all databindings and updates any necessary values in the
augmented HTML, then re-renders the entire HTML DOM tree to refresh the page.
12
+ =
How React Renders Components
• React components exist in JS files which contain HTML embedded into JSX.
• A React view is built from independent components with isolated states.
• The base ReactDOM.Render() JavaScript method renders the view by calling the render()
method on each element in the DOM tree. Render() returns HTML.
• Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called
“props”) and return React elements describing what should appear on the screen.
• The view consists of independent components which are only updated when the individual
state changes.
• When data bound to a React element changes, the render() method is triggered on the
element and it is updated in isolation.
13
Every React component
has a Render() method
React Virtual DOM
• React handles the DOM
considerably more efficient than
Angular’s Digest Cycle does.
• React keeps a copy of the DOM in
memory, called the Virtual DOM.
• When data on any component
changes, React updates the Virtual
DOM node associated with the
updated data.
• After updating the Virtual DOM,
React diffs it with the actual DOM.
• React uses the results of the diff to
re-render any updated component
on the actual DOM.
14
Angular Digest Cycle
15
• The Digest Cycle is the process by which Angular updates the view
after model data has been updated.
• The Angular framework registers a watch on all data bound
elements.
• When a data bound element changes, (or the digest cycle is
manually triggered in code), the framework evaluates every data
bound element to check if the value has changed.
• The framework re-renders the entire DOM with the updated data.
Data Binding
16
• Angular uses 2 – Way Data Binding, where any updates on the UI
are bound to the model automatically, and any model updates
(service, async communication, etc) are immediately visible to the
UI. Updating any piece of data triggers the Digest Cycle.
• React uses 1 – Way Data Binding, where updates to the UI trigger
events which call functions on the data model that update the data
and state. Remember that components have individual data
models.
Disclaimer: Angular has
optimized the Digest Cycle to
work more efficiently, but I
will leave the details for a
further discussion
Big Picture Comparison
• Angular’s Digest Cycle updates the entire
view when any data bound to a UI element is
updated.
• Angular is a framework, so it contains a lot of
useful of out-of-the box functionality that React
would require customization to implement.
• Angular is versioned and the standard
implementation is well documented by Google.
• Angular has a difficult learning curve, and in
general is harder to debug than React.
• The Angular CLI makes setup and development
very easy, however.
17
• React diffs DOM updates using a copy of the
DOM in memory and only updates relevant
view components when data is updated.
• The React landscape is quite mature,
however, and it is easy to find tools to help
streamline development. As a result, React
apps are typically coupled with other JS
libraries.
• There is no standard React project
configuration, and only a set of best practices
(Redux, Flux, ect)
• In my experience, React is easier to debug
because the render() method is exposed in
source code.
• Use the create-react-app tool to do (almost)
as much as the Angular CLI
Another Comparison Table

More Related Content

What's hot (20)

React js Online Training
React js Online TrainingReact js Online Training
React js Online Training
Learntek1
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
Alessandro Valenti
 
Reactjs
Reactjs Reactjs
Reactjs
Neha Sharma
 
React Js Simplified
React Js SimplifiedReact Js Simplified
React Js Simplified
Sunil Yadav
 
Intro to React
Intro to ReactIntro to React
Intro to React
Eric Westfall
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
Jennifer Estrada
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Lohith Goudagere Nagaraj
 
React render props
React render propsReact render props
React render props
Saikat Samanta
 
Introduction to react js
Introduction to react jsIntroduction to react js
Introduction to react js
Aeshan Wijetunge
 
Introduction to ReactJs & fundamentals
Introduction to ReactJs & fundamentalsIntroduction to ReactJs & fundamentals
Introduction to ReactJs & fundamentals
websyndicate
 
React js
React jsReact js
React js
Nikhil Karkra
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 
ReactJs
ReactJsReactJs
ReactJs
Sahana Banerjee
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Bethmi Gunasekara
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
Ritesh Mehrotra
 
React introduction
React introductionReact introduction
React introduction
Kashyap Parmar
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
Rob Quick
 
React.js
React.jsReact.js
React.js
Łukasz Kużyński
 

Similar to Comparing Angular and React JS for SPAs (20)

Angular vs.pdf
Angular vs.pdfAngular vs.pdf
Angular vs.pdf
SophiaJasper
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
React vs. angular   a comprehensive guideline for choosing right front-end fr...React vs. angular   a comprehensive guideline for choosing right front-end fr...
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
Sebastian Pederiva
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Angular vs react comparison in 2022 which is better and why
Angular vs react comparison in 2022 which is better and whyAngular vs react comparison in 2022 which is better and why
Angular vs react comparison in 2022 which is better and why
Noman Shaikh
 
AngularJS Vs ReactJS_ What’s The Difference_.pdf
AngularJS Vs ReactJS_  What’s The Difference_.pdfAngularJS Vs ReactJS_  What’s The Difference_.pdf
AngularJS Vs ReactJS_ What’s The Difference_.pdf
Onviqa Pvt. Ltd.
 
Angular vs react
Angular vs reactAngular vs react
Angular vs react
Infinijith Technologies
 
Which technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdfWhich technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdf
Moon Technolabs Pvt. Ltd.
 
React.js vs angular.js a comparison
React.js vs angular.js a comparisonReact.js vs angular.js a comparison
React.js vs angular.js a comparison
Narola Infotech
 
React vs angular which front end framework should you choose and why
React vs angular which front end framework should you choose and whyReact vs angular which front end framework should you choose and why
React vs angular which front end framework should you choose and why
Katy Slemon
 
React vs angular what to choose for your app
React vs angular what to choose for your appReact vs angular what to choose for your app
React vs angular what to choose for your app
Concetto Labs
 
Angular vs React: Making an Informed Decision for Your Web Development
Angular vs React: Making an Informed Decision for Your Web DevelopmentAngular vs React: Making an Informed Decision for Your Web Development
Angular vs React: Making an Informed Decision for Your Web Development
FredReynolds2
 
Comparison Between React Vs Angular.pdf
Comparison Between React Vs Angular.pdfComparison Between React Vs Angular.pdf
Comparison Between React Vs Angular.pdf
StephieJohn
 
React js vs angularjs which framework to choose in 2022_
React js vs angularjs  which framework to choose in 2022_React js vs angularjs  which framework to choose in 2022_
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
Angular vs React: Pick the Right Front-End in 2024
Angular vs React: Pick the Right Front-End in 2024Angular vs React: Pick the Right Front-End in 2024
Angular vs React: Pick the Right Front-End in 2024
Consumer Sketch
 
Angular vs React 2019 [UPDATED] - tecHindustan
Angular vs React 2019 [UPDATED] - tecHindustanAngular vs React 2019 [UPDATED] - tecHindustan
Angular vs React 2019 [UPDATED] - tecHindustan
tecHIndustan Solutions
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
React VS Angular- Which is Best for You in 2023?
 React VS Angular- Which is Best for You in 2023? React VS Angular- Which is Best for You in 2023?
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
 AngularJS vs ReactJS: Which One is Best for Next Front-end Development AngularJS vs ReactJS: Which One is Best for Next Front-end Development
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
Andolasoft Inc
 
React vs Angular - Which is best JS Framework for Front-end Development
React vs Angular - Which is best JS Framework for Front-end DevelopmentReact vs Angular - Which is best JS Framework for Front-end Development
React vs Angular - Which is best JS Framework for Front-end Development
Pixlogix Infotech
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
React vs. angular   a comprehensive guideline for choosing right front-end fr...React vs. angular   a comprehensive guideline for choosing right front-end fr...
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
Sebastian Pederiva
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Angular vs react comparison in 2022 which is better and why
Angular vs react comparison in 2022 which is better and whyAngular vs react comparison in 2022 which is better and why
Angular vs react comparison in 2022 which is better and why
Noman Shaikh
 
AngularJS Vs ReactJS_ What’s The Difference_.pdf
AngularJS Vs ReactJS_  What’s The Difference_.pdfAngularJS Vs ReactJS_  What’s The Difference_.pdf
AngularJS Vs ReactJS_ What’s The Difference_.pdf
Onviqa Pvt. Ltd.
 
Which technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdfWhich technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdf
Moon Technolabs Pvt. Ltd.
 
React.js vs angular.js a comparison
React.js vs angular.js a comparisonReact.js vs angular.js a comparison
React.js vs angular.js a comparison
Narola Infotech
 
React vs angular which front end framework should you choose and why
React vs angular which front end framework should you choose and whyReact vs angular which front end framework should you choose and why
React vs angular which front end framework should you choose and why
Katy Slemon
 
React vs angular what to choose for your app
React vs angular what to choose for your appReact vs angular what to choose for your app
React vs angular what to choose for your app
Concetto Labs
 
Angular vs React: Making an Informed Decision for Your Web Development
Angular vs React: Making an Informed Decision for Your Web DevelopmentAngular vs React: Making an Informed Decision for Your Web Development
Angular vs React: Making an Informed Decision for Your Web Development
FredReynolds2
 
Comparison Between React Vs Angular.pdf
Comparison Between React Vs Angular.pdfComparison Between React Vs Angular.pdf
Comparison Between React Vs Angular.pdf
StephieJohn
 
React js vs angularjs which framework to choose in 2022_
React js vs angularjs  which framework to choose in 2022_React js vs angularjs  which framework to choose in 2022_
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
Angular vs React: Pick the Right Front-End in 2024
Angular vs React: Pick the Right Front-End in 2024Angular vs React: Pick the Right Front-End in 2024
Angular vs React: Pick the Right Front-End in 2024
Consumer Sketch
 
Angular vs React 2019 [UPDATED] - tecHindustan
Angular vs React 2019 [UPDATED] - tecHindustanAngular vs React 2019 [UPDATED] - tecHindustan
Angular vs React 2019 [UPDATED] - tecHindustan
tecHIndustan Solutions
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
React VS Angular- Which is Best for You in 2023?
 React VS Angular- Which is Best for You in 2023? React VS Angular- Which is Best for You in 2023?
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
 AngularJS vs ReactJS: Which One is Best for Next Front-end Development AngularJS vs ReactJS: Which One is Best for Next Front-end Development
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
Andolasoft Inc
 
React vs Angular - Which is best JS Framework for Front-end Development
React vs Angular - Which is best JS Framework for Front-end DevelopmentReact vs Angular - Which is best JS Framework for Front-end Development
React vs Angular - Which is best JS Framework for Front-end Development
Pixlogix Infotech
 
Ad

Recently uploaded (20)

Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right WayMigrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdfWhat is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdfHow to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdfLooking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdfWhat is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
How to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdfHow to Choose the Right Web Development Agency.pdf
How to Choose the Right Web Development Agency.pdf
Creative Fosters
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdfLooking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Ad

Comparing Angular and React JS for SPAs

  • 2. Discussion Agenda • React and Angular Tool Overview • Side-By-Side Comparison • Sample Code • Architectural Comparisons: • Component Tree Architecture • Angular Digest Cycle • React Virtual DOM • Data Binding • Big Picture Comparison 2
  • 3. Overview 3 Angular is a Framework for building Web Applications. React is a JavaScript Library for building User Interfaces.
  • 4. Overview 4 Different problems are often best solved using different tools. We will be discussing the features of React and Angular and how they are both best suited for building different types of Single Page Applications.
  • 5. Overview – Developer Interest 5 Interestingly, in the 2017 Stack Overflow survey, React is the most loved technology, while AngularJS is the most used web development technology. In general, developers tend to enjoy working with React very much, while architectural decisions tend to be made favoring Angular. https://insights.stackoverflow.com/survey/2017#technology
  • 6. Overview - Angular 6 • TypeScript-based open-source front-end web application platform for building single page applications. • Uses component based architecture. • Creates components by grouping structure and function into HTML templates. • Developers use components to build apps declaratively. • Provides simple framework solutions for foundational functionality (routing, HTTP, forms, etc) which can be customized. • Digest cycle re-renders entire view when data is updated. • Functionality is organized into modules which are loaded dynamically. • Angular apps are loosely MVC, MVW, etc. • Angular apps need to be built
  • 7. Overview – React 7 • JavaScript library for building user interfaces. • Uses components to build UIs. • React components manage their own internal state • Components are written in JavaScript and JSX • Only contains library functions for building views • Builds views from encapsulated components so UI only updates necessary elements when data changes. • All components contain structure by implementing render() function which returns HTML. • React library is light, and needs outside tools to serve, reuse components, etc. • Standard tools exist, however (ex. create-react- app • React Uis also need to be built.
  • 8. Side-By-Side Comparison of Angular and React - Stats 8
  • 9. Side-By-Side Comparison of Angular and React - Features 9
  • 10. Sample Code <form (ngSubmit)="onSubmit(heroForm)" #heroForm="ngForm"> <div class="form-group"> <label for="name">Name <input class="form-control" name="name" required [(ngModel)]="hero.name"> </label> </div> <button type="submit" [disabled]="!heroForm.form.valid">Submit</b utton> </form> <div [hidden]="!heroForm.form.valid"> {{submitMessage}} </div> 10 var Saves = React.createClass({ getInitialState: function(){ ….. }, handleSubmit: function(e) { … }, render: function() { var savedText = ''; var submitText = 'Save'; if (this.state.saved) { savedText = 'You have saved this home.'; submitText = 'Remove'; } return ( <div className="saves"> <form onSubmit={this.handleSubmit}> <input type="submit" value={submitText} /> </form> {this.state.numSaves} saves. {savedText} </div> ); } }); JavaScript in HTML! JS Render function contains HTML! Angular Template React JS Class
  • 11. Review: Component Based Architecture • Components are UI elements which encapsulate functionality and structure. • Components are custom HTML elements which contain HTML coupled with functionality defined in JavaScript. • Components also contain an isolated data scope. React components use their isolated scope to independently update the view when bound data changes. • The DOM is a tree of components. There is a root component and child components as in the basic DOM. 11
  • 12. How Angular Renders Components • Angular components exist in TypeScript Component files and their corresponding HTML template files. • Angular renders a view by loading the base component (defined in the base module) in TypeScript code and rendering the resulting tree of components. • When Angular renders a component, it loads the component TypeScript code into memory, then renders the resulting augmented HTML into the browser by parsing the HTML template file and adding functionality (events, bound data, etc) from the component code. • When data bound to the view changes, the framework Digest Cycle is triggered to refresh the rendered view. • The Digest Cycle checks all databindings and updates any necessary values in the augmented HTML, then re-renders the entire HTML DOM tree to refresh the page. 12 + =
  • 13. How React Renders Components • React components exist in JS files which contain HTML embedded into JSX. • A React view is built from independent components with isolated states. • The base ReactDOM.Render() JavaScript method renders the view by calling the render() method on each element in the DOM tree. Render() returns HTML. • Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen. • The view consists of independent components which are only updated when the individual state changes. • When data bound to a React element changes, the render() method is triggered on the element and it is updated in isolation. 13 Every React component has a Render() method
  • 14. React Virtual DOM • React handles the DOM considerably more efficient than Angular’s Digest Cycle does. • React keeps a copy of the DOM in memory, called the Virtual DOM. • When data on any component changes, React updates the Virtual DOM node associated with the updated data. • After updating the Virtual DOM, React diffs it with the actual DOM. • React uses the results of the diff to re-render any updated component on the actual DOM. 14
  • 15. Angular Digest Cycle 15 • The Digest Cycle is the process by which Angular updates the view after model data has been updated. • The Angular framework registers a watch on all data bound elements. • When a data bound element changes, (or the digest cycle is manually triggered in code), the framework evaluates every data bound element to check if the value has changed. • The framework re-renders the entire DOM with the updated data.
  • 16. Data Binding 16 • Angular uses 2 – Way Data Binding, where any updates on the UI are bound to the model automatically, and any model updates (service, async communication, etc) are immediately visible to the UI. Updating any piece of data triggers the Digest Cycle. • React uses 1 – Way Data Binding, where updates to the UI trigger events which call functions on the data model that update the data and state. Remember that components have individual data models. Disclaimer: Angular has optimized the Digest Cycle to work more efficiently, but I will leave the details for a further discussion
  • 17. Big Picture Comparison • Angular’s Digest Cycle updates the entire view when any data bound to a UI element is updated. • Angular is a framework, so it contains a lot of useful of out-of-the box functionality that React would require customization to implement. • Angular is versioned and the standard implementation is well documented by Google. • Angular has a difficult learning curve, and in general is harder to debug than React. • The Angular CLI makes setup and development very easy, however. 17 • React diffs DOM updates using a copy of the DOM in memory and only updates relevant view components when data is updated. • The React landscape is quite mature, however, and it is easy to find tools to help streamline development. As a result, React apps are typically coupled with other JS libraries. • There is no standard React project configuration, and only a set of best practices (Redux, Flux, ect) • In my experience, React is easier to debug because the render() method is exposed in source code. • Use the create-react-app tool to do (almost) as much as the Angular CLI