SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

State Management in Angular/React
State Management in Angular/ReactState Management in Angular/React
State Management in Angular/ReactDEV Cafe
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)Tomáš Drenčák
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooksMaulik Shah
 
iOS Modular Architecture with Tuist
iOS Modular Architecture with TuistiOS Modular Architecture with Tuist
iOS Modular Architecture with Tuist정민 안
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react nativeDani Akash
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDDKnoldus Inc.
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUIBongwon Lee
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming PrinciplesAndrii Lundiak
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Previewvaluebound
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
안정적인 서비스 운영 2014.03
안정적인 서비스 운영   2014.03안정적인 서비스 운영   2014.03
안정적인 서비스 운영 2014.03Changyol BAEK
 

La actualidad más candente (20)

State Management in Angular/React
State Management in Angular/ReactState Management in Angular/React
State Management in Angular/React
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
 
React js
React jsReact js
React js
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
iOS Modular Architecture with Tuist
iOS Modular Architecture with TuistiOS Modular Architecture with Tuist
iOS Modular Architecture with Tuist
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
Pengenalan ReactJS
Pengenalan ReactJS Pengenalan ReactJS
Pengenalan ReactJS
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDD
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming Principles
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
안정적인 서비스 운영 2014.03
안정적인 서비스 운영   2014.03안정적인 서비스 운영   2014.03
안정적인 서비스 운영 2014.03
 

Similar a React Tech Salon

ReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOMReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOMMarc Cyr
 
Learning React - I
Learning React - ILearning React - I
Learning React - IMitch Chen
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theoryjobinThomas54
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETAlan Hecht
 
Introduction to react native with redux
Introduction to react native with reduxIntroduction to react native with redux
Introduction to react native with reduxMike Melusky
 
An evening with React Native
An evening with React NativeAn evening with React Native
An evening with React NativeMike Melusky
 
React native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsReact native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsJimit Shah
 
Meteor Revolution: From DDP to Blaze Reactive Rendering
Meteor Revolution: From DDP to Blaze Reactive Rendering Meteor Revolution: From DDP to Blaze Reactive Rendering
Meteor Revolution: From DDP to Blaze Reactive Rendering Massimo Sgrelli
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?Balajihope
 
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15GreeceJS
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementZach Lendon
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Zach Lendon
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webSigma Software
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and ReactMike Melusky
 
RubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineRubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineFlorian Dutey
 

Similar a React Tech Salon (20)

ReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOMReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOM
 
Learning React - I
Learning React - ILearning React - I
Learning React - I
 
React.js at Cortex
React.js at CortexReact.js at Cortex
React.js at Cortex
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
 
Meteor + React
Meteor + ReactMeteor + React
Meteor + React
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
 
Introduction to react native with redux
Introduction to react native with reduxIntroduction to react native with redux
Introduction to react native with redux
 
An evening with React Native
An evening with React NativeAn evening with React Native
An evening with React Native
 
React introduction
React introductionReact introduction
React introduction
 
React native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsReact native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile Apps
 
Meteor Revolution: From DDP to Blaze Reactive Rendering
Meteor Revolution: From DDP to Blaze Reactive Rendering Meteor Revolution: From DDP to Blaze Reactive Rendering
Meteor Revolution: From DDP to Blaze Reactive Rendering
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
 
Nodejs overview
Nodejs overviewNodejs overview
Nodejs overview
 
RubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineRubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipeline
 

Último

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 

Último (20)

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

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