SlideShare a Scribd company logo
React
Chenguang Zhang
TPM, Hulu Beijing
A little bit of history
The original Web The Ajax Web
A little bit of history
• Ajax is “the method of exchanging data with a
server, and updating parts of a web page -
without reloading the entire page.”
• Ajax is also the foundation of modern web apps.
A little bit of history
Ajax Challenges
Exchange data
Render view
MVC/MVVM solutions
AngularJS
Ember
Backbone
React
MVC/MVVM solutions
• Benefits
• Improved design architecture
• Promotes code reusability
• Easy to add/remove components
• Better teamwork
• Drawbacks
• Separate code, not concerns
• Callback, linking function….
• 2-way data binding
What’s the concern?
• Data changing overtime is the root of all evil
• Render data on time ZERO and time T are totally
different
• 2-way data binding doesn’t fix it correctly
Why React?
• We built React to solve one problem: building
large applications with data that changes over
time.
• From React Blog - Why React
A React Example
Render to DOM?
A template language?
Key ideas
• Components, not templates.
• Re-render, don’t mutate.
• Virtual DOM is simple and fast.
Components
• Components are self-contained
• Reusable
• Composable
• Unit testable
1-way data flow
• Data flows down
• Props is immutable
• States is mutable
• Anything (Props, States,
Handlers, Styles) can be
passed to children as props
• Event flows up
• Through parent passed
handler props
Parent Component
Child Component
Props
States
States
Passed to child as props
Data flows down
Event flows up
Looks familiar?
Just like DOM
Components
• Components are self-contained
• Get props from anyone
• Own the states
• Own the handler to change the states
Re-render
• To solve the problem of data changing over time
• Let’s go back to 1990s.
• Re-render the whole app on every update
• Data is the single source of truth
Wait…
• Performance issue!
• Ok, why?
Why re-render is heavy?
• Javascript is not that slow…
• But DOM is very slow!
Virtual DOM
• The key tech that make the “Re-render” a smart
decision
Virtual DOM
• A pure javascript, in-memory representation of
DOM
• Render the Virtual DOM whenever something
changes
• React translate the diff into batch DOM ops
• Apply the batch ops to Real DOM to sync
Virtual DOM
React
Components
Virtual DOM
Computed
Batch DOM
ops
Real DOM
Auto update all in 60 fps
Virtual DOM
• Further optimization based on component
structure
• Even faster than manual Vanilla JS DOM ops
• No only traditional DOM, but also others
• Flipboard build a 60 fps web app by applying
React to Canvas
• Netflix build TV apps by applying React to
Gibbon
Virtual DOM
• There is a standalone open-source Virtual DOM
implementation inspired by React
• And also a lot of view OR MVC/MVVM solutions
built on top of it
• Ember 2.x and Angular 2.x will also introduce
Virtual DOM
More things that power up
React.
JSX
• JSX lets you create JavaScript objects using
HTML syntax.
• Less code, more friendly.
React.createElement('a', {href: ‘http://www.hulu.com/'}, 'Hello!')
<a href=“http://www.hulu.com”>Hello!</a>
JSX
• Will be translated into Javascript to be executed
• Offline - react-tools
• In-Browser - JSXTransformer
• It doesn't alter the semantics of JavaScript.
Developer Tool
• React Developer Tools
• A chrome extension to inspect the React
component hierarchies
React IDE
• React IDE is pending on http://nuclide.io/
• Built on top of Atom
Flux
• A application architecture that complements
React by utilizing a unidirectional data flow
MVC v.s. Flux
Complex MVC
Complex Flux
Relay + GraphQL
• Relay is a new framework from Facebook that
provides data-fetching functionality for React
applications.
• GraphQL is a data querying language designed
to describe the complex, nested data
dependencies of modern applications.
• Not open-sourced yet, but it will soon…
GraphQL
GraphQL
Relay + GraphQL
Relay + GraphQL
Relay + GraphQL
Relay
• Similar with Flux
• But there is only one Store
• Can be used alone OR together
• Find exactly the right data for the React Components via
GraphQL
• Resolve the props dependency of parent-child
components
• A transparent data cache
• It also solve the data problem for React Native
React Native
• A framework allow you to write native mobile apps
in Javascript and React
• Write in Javascript, and it will apply JS UI update
to Native UI update
• Learn once, write anywhere.
React Native
• Use Javascript declared styles instead of CSS
var styles = StyleSheet.create({
base: {
width: 38,
height: 38,
},
background: {
backgroundColor: '#222222',
},
active: {
borderWidth: 2,
borderColor: '#00ff00',
},
});
<Text style={styles.base} />
<View style={styles.background} />
<View style={[styles.base, styles.background]} />
<View style={[styles.base, this.state.active && styles.active]} />
React Today
• Facebook / Instagram
• Yahoo Mail
• Netflix All Platform
• HipChat (web version)
• Github Atom IDE
• Flipboard
• Taobao
React Ecosystem
GraphQL (API Gateway)
Server Side APIs
Relay (Data Framework)Flux (Event Framework)
React (JSX, Components, JS Styles)
React Native (Native Code)React Web (Virtual DOM)
Open Discussion
• Will Browser provide native support for virtual
DOM?
• NO, cause there is legacy spec
• But maybe YES for the wild wild Chrome OS…
Open Discussion
• Will React Native change the way that people
write the Mobile App?
• Still too early, cause it didn’t solve any critical
problem for complex native apps
• But it will allow Javascript coder to create native
apps easier
• End of the war of HTML5 and Native App
Open Discussion
• Which one is easier to refactor existing code?
• Replace all DOM actions with virtual DOM
actions
• Use React directly to rewrite the View
Open Discussion
• Is React always faster & better than manual ops
DOM?
• For most case, it is true
• But manual ops gives you more space to do
specific optimization
• Atom removed React in text editor to use
Shadow DOM https://github.com/atom/atom/
issues/3677
Reference
• Why react?
• http://facebook.github.io/react/blog/2013/06/05/
why-react.html
Reference
• Understand the Virtual DOM
• http://fluentconf.com/fluent2014/public/
schedule/detail/32395
• The Virtual DOM diff algorithm
• http://calendar.perfplanet.com/2013/diff/
• https://github.com/Matt-Esch/virtual-dom
References
• Write your first react app
• https://github.com/mikechau/react-primer-draft
• Find the wheels that have already been invented
• https://github.com/enaqx/awesome-react
Reference
• Relay + GraphQL Deck on React Conf 2015
• https://speakerdeck.com/relayjs/data-fetching-
for-react-applications
• Unofficial Relay FAQ
• https://gist.github.com/wincent/
598fa75e22bdfa44cf47
Reference
• React & Flux on F8 2014
• Facebook message box
• https://youtu.be/nYkdrAPrdcw
• React Native & Relay on F8 2015
• Facebook comments box
• https://youtu.be/X6YbAKiLCLU

More Related Content

PDF
Optimizing ModSecurity on NGINX and NGINX Plus
PPT
Twitter - Architecture and Scalability lessons
PPTX
EVCache at Netflix
PPTX
TIBCO vs MuleSoft Differentiators
PPTX
Art of refactoring - Code Smells and Microservices Antipatterns
PDF
Introduction to MuleSoft Anytime Platform
PDF
Devops Strategy Roadmap Lifecycle Ppt Powerpoint Presentation Slides Complete...
PPTX
FinOps for private cloud
Optimizing ModSecurity on NGINX and NGINX Plus
Twitter - Architecture and Scalability lessons
EVCache at Netflix
TIBCO vs MuleSoft Differentiators
Art of refactoring - Code Smells and Microservices Antipatterns
Introduction to MuleSoft Anytime Platform
Devops Strategy Roadmap Lifecycle Ppt Powerpoint Presentation Slides Complete...
FinOps for private cloud

What's hot (20)

PDF
Incident Management in the Age of DevOps and SRE
PDF
Kafka At Scale in the Cloud
PDF
Benefits of Stream Processing and Apache Kafka Use Cases
PDF
Microservice Architecture
PDF
Introduction to the Disruptor
PDF
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
PPTX
Vanrish Mulesoft Integration architect ppt
PPTX
Boas práticas de arquitetura e operações
PPTX
Rethinking Best Practices
PDF
The Service Mesh: It's about Traffic
PDF
Cruise Control: Effortless management of Kafka clusters
PDF
DevOps Powerpoint Presentation Slides
PPTX
Epic Estimation 2019
PPTX
JIRA Service Desk presentation
PPTX
DevOps Foundation
PPTX
Micro frontend architecture_presentation_ssoni
PPTX
PDF
Introduction to WebSockets Presentation
PDF
Performance culture through the looking-glass - performance.now() 2022
PDF
Design Spikes for the Dual-Track Agile Process
Incident Management in the Age of DevOps and SRE
Kafka At Scale in the Cloud
Benefits of Stream Processing and Apache Kafka Use Cases
Microservice Architecture
Introduction to the Disruptor
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
Vanrish Mulesoft Integration architect ppt
Boas práticas de arquitetura e operações
Rethinking Best Practices
The Service Mesh: It's about Traffic
Cruise Control: Effortless management of Kafka clusters
DevOps Powerpoint Presentation Slides
Epic Estimation 2019
JIRA Service Desk presentation
DevOps Foundation
Micro frontend architecture_presentation_ssoni
Introduction to WebSockets Presentation
Performance culture through the looking-glass - performance.now() 2022
Design Spikes for the Dual-Track Agile Process
Ad

Similar to React Tech Salon (20)

PPTX
ReactJS - Re-rendering pages in the age of the mutable DOM
PDF
Learning React - I
PPTX
React.js at Cortex
PDF
Web Development with Delphi and React - ITDevCon 2016
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PDF
Meteor + React
PPT
Intro to SPA using JavaScript & ASP.NET
PPTX
React js
PPTX
Introduction to react native with redux
PPTX
mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
PPTX
An evening with React Native
PPSX
React introduction
PPTX
React native - React(ive) Way To Build Native Mobile Apps
PDF
Meteor Revolution: From DDP to Blaze Reactive Rendering
PPTX
What is Mean Stack Development ?
PDF
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
PDF
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
PDF
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
PPTX
Isomorphic JavaScript – future of the web
PPTX
Progressive Web Apps and React
ReactJS - Re-rendering pages in the age of the mutable DOM
Learning React - I
React.js at Cortex
Web Development with Delphi and React - ITDevCon 2016
Reactjs notes.pptx for web development- tutorial and theory
Meteor + React
Intro to SPA using JavaScript & ASP.NET
React js
Introduction to react native with redux
mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
An evening with React Native
React introduction
React native - React(ive) Way To Build Native Mobile Apps
Meteor Revolution: From DDP to Blaze Reactive Rendering
What is Mean Stack Development ?
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
Isomorphic JavaScript – future of the web
Progressive Web Apps and React
Ad

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administration Chapter 2
PDF
Understanding Forklifts - TECH EHS Solution
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
top salesforce developer skills in 2025.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Introduction to Artificial Intelligence
PPT
Introduction Database Management System for Course Database
PPTX
Transform Your Business with a Software ERP System
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Operating system designcfffgfgggggggvggggggggg
Odoo POS Development Services by CandidRoot Solutions
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administration Chapter 2
Understanding Forklifts - TECH EHS Solution
2025 Textile ERP Trends: SAP, Odoo & Oracle
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Design an Analysis of Algorithms II-SECS-1021-03
top salesforce developer skills in 2025.pdf
How Creative Agencies Leverage Project Management Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Upgrade and Innovation Strategies for SAP ERP Customers
Navsoft: AI-Powered Business Solutions & Custom Software Development
Introduction to Artificial Intelligence
Introduction Database Management System for Course Database
Transform Your Business with a Software ERP System
CHAPTER 2 - PM Management and IT Context
Design an Analysis of Algorithms I-SECS-1021-03
Operating system designcfffgfgggggggvggggggggg

React Tech Salon

  • 2. A little bit of history The original Web The Ajax Web
  • 3. A little bit of history • Ajax is “the method of exchanging data with a server, and updating parts of a web page - without reloading the entire page.” • Ajax is also the foundation of modern web apps.
  • 4. A little bit of history Ajax Challenges Exchange data Render view MVC/MVVM solutions AngularJS Ember Backbone React
  • 5. MVC/MVVM solutions • Benefits • Improved design architecture • Promotes code reusability • Easy to add/remove components • Better teamwork • Drawbacks • Separate code, not concerns • Callback, linking function…. • 2-way data binding
  • 6. What’s the concern? • Data changing overtime is the root of all evil • Render data on time ZERO and time T are totally different • 2-way data binding doesn’t fix it correctly
  • 7. Why React? • We built React to solve one problem: building large applications with data that changes over time. • From React Blog - Why React
  • 8. A React Example Render to DOM? A template language?
  • 9. Key ideas • Components, not templates. • Re-render, don’t mutate. • Virtual DOM is simple and fast.
  • 10. Components • Components are self-contained • Reusable • Composable • Unit testable
  • 11. 1-way data flow • Data flows down • Props is immutable • States is mutable • Anything (Props, States, Handlers, Styles) can be passed to children as props • Event flows up • Through parent passed handler props Parent Component Child Component Props States States
  • 12. Passed to child as props Data flows down Event flows up
  • 14. Components • Components are self-contained • Get props from anyone • Own the states • Own the handler to change the states
  • 15. Re-render • To solve the problem of data changing over time • Let’s go back to 1990s. • Re-render the whole app on every update • Data is the single source of truth
  • 17. Why re-render is heavy? • Javascript is not that slow… • But DOM is very slow!
  • 18. Virtual DOM • The key tech that make the “Re-render” a smart decision
  • 19. Virtual DOM • A pure javascript, in-memory representation of DOM • Render the Virtual DOM whenever something changes • React translate the diff into batch DOM ops • Apply the batch ops to Real DOM to sync
  • 20. Virtual DOM React Components Virtual DOM Computed Batch DOM ops Real DOM Auto update all in 60 fps
  • 21. Virtual DOM • Further optimization based on component structure • Even faster than manual Vanilla JS DOM ops • No only traditional DOM, but also others • Flipboard build a 60 fps web app by applying React to Canvas • Netflix build TV apps by applying React to Gibbon
  • 22. Virtual DOM • There is a standalone open-source Virtual DOM implementation inspired by React • And also a lot of view OR MVC/MVVM solutions built on top of it • Ember 2.x and Angular 2.x will also introduce Virtual DOM
  • 23. More things that power up React.
  • 24. JSX • JSX lets you create JavaScript objects using HTML syntax. • Less code, more friendly. React.createElement('a', {href: ‘http://www.hulu.com/'}, 'Hello!') <a href=“http://www.hulu.com”>Hello!</a>
  • 25. JSX • Will be translated into Javascript to be executed • Offline - react-tools • In-Browser - JSXTransformer • It doesn't alter the semantics of JavaScript.
  • 26. Developer Tool • React Developer Tools • A chrome extension to inspect the React component hierarchies
  • 27. React IDE • React IDE is pending on http://nuclide.io/ • Built on top of Atom
  • 28. Flux • A application architecture that complements React by utilizing a unidirectional data flow
  • 32. Relay + GraphQL • Relay is a new framework from Facebook that provides data-fetching functionality for React applications. • GraphQL is a data querying language designed to describe the complex, nested data dependencies of modern applications. • Not open-sourced yet, but it will soon…
  • 38. Relay • Similar with Flux • But there is only one Store • Can be used alone OR together • Find exactly the right data for the React Components via GraphQL • Resolve the props dependency of parent-child components • A transparent data cache • It also solve the data problem for React Native
  • 39. React Native • A framework allow you to write native mobile apps in Javascript and React • Write in Javascript, and it will apply JS UI update to Native UI update • Learn once, write anywhere.
  • 40. React Native • Use Javascript declared styles instead of CSS var styles = StyleSheet.create({ base: { width: 38, height: 38, }, background: { backgroundColor: '#222222', }, active: { borderWidth: 2, borderColor: '#00ff00', }, }); <Text style={styles.base} /> <View style={styles.background} /> <View style={[styles.base, styles.background]} /> <View style={[styles.base, this.state.active && styles.active]} />
  • 41. React Today • Facebook / Instagram • Yahoo Mail • Netflix All Platform • HipChat (web version) • Github Atom IDE • Flipboard • Taobao
  • 42. React Ecosystem GraphQL (API Gateway) Server Side APIs Relay (Data Framework)Flux (Event Framework) React (JSX, Components, JS Styles) React Native (Native Code)React Web (Virtual DOM)
  • 43. Open Discussion • Will Browser provide native support for virtual DOM? • NO, cause there is legacy spec • But maybe YES for the wild wild Chrome OS…
  • 44. Open Discussion • Will React Native change the way that people write the Mobile App? • Still too early, cause it didn’t solve any critical problem for complex native apps • But it will allow Javascript coder to create native apps easier • End of the war of HTML5 and Native App
  • 45. Open Discussion • Which one is easier to refactor existing code? • Replace all DOM actions with virtual DOM actions • Use React directly to rewrite the View
  • 46. Open Discussion • Is React always faster & better than manual ops DOM? • For most case, it is true • But manual ops gives you more space to do specific optimization • Atom removed React in text editor to use Shadow DOM https://github.com/atom/atom/ issues/3677
  • 47. Reference • Why react? • http://facebook.github.io/react/blog/2013/06/05/ why-react.html
  • 48. Reference • Understand the Virtual DOM • http://fluentconf.com/fluent2014/public/ schedule/detail/32395 • The Virtual DOM diff algorithm • http://calendar.perfplanet.com/2013/diff/ • https://github.com/Matt-Esch/virtual-dom
  • 49. References • Write your first react app • https://github.com/mikechau/react-primer-draft • Find the wheels that have already been invented • https://github.com/enaqx/awesome-react
  • 50. Reference • Relay + GraphQL Deck on React Conf 2015 • https://speakerdeck.com/relayjs/data-fetching- for-react-applications • Unofficial Relay FAQ • https://gist.github.com/wincent/ 598fa75e22bdfa44cf47
  • 51. Reference • React & Flux on F8 2014 • Facebook message box • https://youtu.be/nYkdrAPrdcw • React Native & Relay on F8 2015 • Facebook comments box • https://youtu.be/X6YbAKiLCLU