SlideShare a Scribd company logo
3 Reasons to Love React
A JavaScript library for building User Interfaces
“The art of programming is
the art of organizing
complexity”
- Edsger W. Dijkstra
What is React?
View in MVC
CommentBox
- CommentForm
- CommentList
Comment
Why React?
1. Reuseable & Testable - React Component
2. Performance - Virtual DOM
3. Build UI with data changes over time -
One-way data flow
1. Reuseable & Testable
React Component
Challenges in Traditional Approach
1. No business logic in templates
- Need more flexibility than {{#each}} and {{#if}}Poor
- Separation of Concerns
Server
(Rails)
ERB template
Client
(Backbone)
Handlebars template
React Components React ComponentsIsomorphic!
React Components - basic building blocks
providing attributes specifies the textContent.
JSX - XML-like syntax extension to JavaScript
Note:
- class is discouraged as XML attribute, use className instead
- JSXTransformer to JS
Render Component
Server-side Rendering - Great for SEO
2. Performance
Virtual DOM
Challenges in Traditional Approach
2. Re-render the whole UI aggressively
Virtual DOM
● Diff - the new one from the old one
● Reconciliation - knows to only update the
changed parts
● Minimal DOM manipulation
● Put in queues, batched reads & writes
Benchmarks - @ 25 items
Key-Value
Observing
(Ember/Meteor)
Virtual DOM
Initial render ~ 5 ms ~ 6 ms
Warm updates ~ 2 ms ~ 2 ms
Steady state
memory
(force CG)
~ 11.8 mb ~ 7.8 mb
Benchmarks - @ 10k items
KVO
(Ember/Meteor)
Virtual DOM
Initial render ~ 540 ms ~ 18 ms
Warm updates ~ 215 ms ~ 4.5 ms
Steady state
memory
(force CG)
~ 30 mb ~ 9 mb
Complexity (perf) comparison
KVO
(Ember/Meteor)
Virtual DOM
(React)
CPU
(on update)
O(1) O(v)
Memory
(steady state)
O(m)
size of your model
O(v)
size of your view
m >> v
3. Build UI with data
changes over time
One-way data flow
3. Complicated two-way data binding
Challenges in Traditional Approach
model 1
model2
model3
view 2
view 3
view 1
Unidirectional Data Flow
- State is mutable vs Prop is immutable
(Idempotence)
Parent Component
Children Components
- manage the state
- Pass its state down via props
State - top level data, change when setState()
Props - Pass data down, cannot be modified
Events - re-render itself after setState()
camelCase naming convention
Why React?
1. Reusable & Testable - React Component
2. Performance - Virtual DOM
3. Build UI with data changes over time -
One-way data flow
@victorleungtw
Don’t call me, I’ll callback you. I promise!

More Related Content

Viewers also liked

Characterization Theme
Characterization ThemeCharacterization Theme
Characterization Themenstearns
 
Characters presentation
Characters presentationCharacters presentation
Characters presentation
theloungelizard
 
Conflict Management
Conflict ManagementConflict Management
Conflict Management
Sivathanu N
 
Harnessing Disagreement for Event Semantics
Harnessing Disagreement for Event SemanticsHarnessing Disagreement for Event Semantics
Harnessing Disagreement for Event Semantics
Lora Aroyo
 
How do you react to conflict
How do you react to conflictHow do you react to conflict
How do you react to conflict
ncsstaff
 
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
NEUROSERVICE
 
Expressing agreement and disagreement
Expressing agreement and disagreementExpressing agreement and disagreement
Expressing agreement and disagreementMaría Barrillo
 
Expressing agreement and disagreement
Expressing agreement and disagreementExpressing agreement and disagreement
Expressing agreement and disagreementrankyaku
 

Viewers also liked (9)

Characterization Theme
Characterization ThemeCharacterization Theme
Characterization Theme
 
Characters presentation
Characters presentationCharacters presentation
Characters presentation
 
Feedback presentation
Feedback presentationFeedback presentation
Feedback presentation
 
Conflict Management
Conflict ManagementConflict Management
Conflict Management
 
Harnessing Disagreement for Event Semantics
Harnessing Disagreement for Event SemanticsHarnessing Disagreement for Event Semantics
Harnessing Disagreement for Event Semantics
 
How do you react to conflict
How do you react to conflictHow do you react to conflict
How do you react to conflict
 
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
Multi-Electrode Array Technique - Characterization of LTP profiles in wt and ...
 
Expressing agreement and disagreement
Expressing agreement and disagreementExpressing agreement and disagreement
Expressing agreement and disagreement
 
Expressing agreement and disagreement
Expressing agreement and disagreementExpressing agreement and disagreement
Expressing agreement and disagreement
 

Similar to 3 Reasons to Love React

Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)
camunda services GmbH
 
Om & React.js
Om & React.jsOm & React.js
Om & React.js
Kamil Toman
 
Lift Framework
Lift FrameworkLift Framework
Lift Framework
Jeffrey Groneberg
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repositorynobby
 
"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин
Fwdays
 
2018 02-22 React, Redux & Building Applications that Scale | React
2018 02-22 React, Redux & Building Applications that Scale | React2018 02-22 React, Redux & Building Applications that Scale | React
2018 02-22 React, Redux & Building Applications that Scale | React
Codifly
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
Skanda Shastry
 
MVVM
MVVMMVVM
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
MLconf
 
S3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using sparkS3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using spark
Demi Ben-Ari
 
The Pill for Your Migration Hell
The Pill for Your Migration HellThe Pill for Your Migration Hell
The Pill for Your Migration Hell
Databricks
 
The Road To Redux
The Road To ReduxThe Road To Redux
The Road To Redux
Jeffrey Sanchez
 
Clustered Architecture Patterns Delivering Scalability And Availability
Clustered Architecture Patterns Delivering Scalability And AvailabilityClustered Architecture Patterns Delivering Scalability And Availability
Clustered Architecture Patterns Delivering Scalability And AvailabilityConSanFrancisco123
 
EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)
Scott Mansfield
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
weili_at_slideshare
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Finaljucaab
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson
 
J2ee connector architecture
J2ee connector architectureJ2ee connector architecture
J2ee connector architecture
Subhasis Nayak
 

Similar to 3 Reasons to Love React (20)

Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)Camunda BPM 7.2: Performance and Scalability (English)
Camunda BPM 7.2: Performance and Scalability (English)
 
Om & React.js
Om & React.jsOm & React.js
Om & React.js
 
Lec7Handout.ppt
Lec7Handout.pptLec7Handout.ppt
Lec7Handout.ppt
 
Lift Framework
Lift FrameworkLift Framework
Lift Framework
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин
 
2018 02-22 React, Redux & Building Applications that Scale | React
2018 02-22 React, Redux & Building Applications that Scale | React2018 02-22 React, Redux & Building Applications that Scale | React
2018 02-22 React, Redux & Building Applications that Scale | React
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
 
MVVM
MVVMMVVM
MVVM
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
 
S3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using sparkS3 cassandra or outer space? dumping time series data using spark
S3 cassandra or outer space? dumping time series data using spark
 
The Pill for Your Migration Hell
The Pill for Your Migration HellThe Pill for Your Migration Hell
The Pill for Your Migration Hell
 
The Road To Redux
The Road To ReduxThe Road To Redux
The Road To Redux
 
Clustered Architecture Patterns Delivering Scalability And Availability
Clustered Architecture Patterns Delivering Scalability And AvailabilityClustered Architecture Patterns Delivering Scalability And Availability
Clustered Architecture Patterns Delivering Scalability And Availability
 
EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)EVCache & Moneta (GoSF)
EVCache & Moneta (GoSF)
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAs
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
J2ee connector architecture
J2ee connector architectureJ2ee connector architecture
J2ee connector architecture
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

3 Reasons to Love React

  • 1. 3 Reasons to Love React A JavaScript library for building User Interfaces
  • 2.
  • 3. “The art of programming is the art of organizing complexity” - Edsger W. Dijkstra
  • 4. What is React? View in MVC CommentBox - CommentForm - CommentList Comment
  • 5. Why React? 1. Reuseable & Testable - React Component 2. Performance - Virtual DOM 3. Build UI with data changes over time - One-way data flow
  • 6. 1. Reuseable & Testable React Component
  • 7. Challenges in Traditional Approach 1. No business logic in templates - Need more flexibility than {{#each}} and {{#if}}Poor - Separation of Concerns Server (Rails) ERB template Client (Backbone) Handlebars template React Components React ComponentsIsomorphic!
  • 8. React Components - basic building blocks providing attributes specifies the textContent.
  • 9. JSX - XML-like syntax extension to JavaScript Note: - class is discouraged as XML attribute, use className instead - JSXTransformer to JS
  • 11. Server-side Rendering - Great for SEO
  • 13. Challenges in Traditional Approach 2. Re-render the whole UI aggressively
  • 14. Virtual DOM ● Diff - the new one from the old one ● Reconciliation - knows to only update the changed parts ● Minimal DOM manipulation ● Put in queues, batched reads & writes
  • 15. Benchmarks - @ 25 items Key-Value Observing (Ember/Meteor) Virtual DOM Initial render ~ 5 ms ~ 6 ms Warm updates ~ 2 ms ~ 2 ms Steady state memory (force CG) ~ 11.8 mb ~ 7.8 mb
  • 16. Benchmarks - @ 10k items KVO (Ember/Meteor) Virtual DOM Initial render ~ 540 ms ~ 18 ms Warm updates ~ 215 ms ~ 4.5 ms Steady state memory (force CG) ~ 30 mb ~ 9 mb
  • 17. Complexity (perf) comparison KVO (Ember/Meteor) Virtual DOM (React) CPU (on update) O(1) O(v) Memory (steady state) O(m) size of your model O(v) size of your view m >> v
  • 18. 3. Build UI with data changes over time One-way data flow
  • 19.
  • 20. 3. Complicated two-way data binding Challenges in Traditional Approach model 1 model2 model3 view 2 view 3 view 1
  • 21. Unidirectional Data Flow - State is mutable vs Prop is immutable (Idempotence) Parent Component Children Components - manage the state - Pass its state down via props
  • 22. State - top level data, change when setState()
  • 23. Props - Pass data down, cannot be modified
  • 24. Events - re-render itself after setState() camelCase naming convention
  • 25. Why React? 1. Reusable & Testable - React Component 2. Performance - Virtual DOM 3. Build UI with data changes over time - One-way data flow
  • 26. @victorleungtw Don’t call me, I’ll callback you. I promise!