SlideShare a Scribd company logo
A New Way to Build Awesome Web Applications
John Need
Senior UI Developer
Twitter : @johnneed
Blog : johnneed.com
Email : johnneed@johnneed.com
+ =
React + Flux = Joy
A View Rendering Engine A Design Pattern A method for building
ginormous web
applications that retain
"Conceptual Simplicity"
even as they grow
Conceptual Simplicity
A model that fits in your head
And doesn't change even if your app gets huge
A Bit About React
• React only renders views. It’s not a SPA framework.
• React was started by Jordan Walke, a developer at
Facebook in 2011
• Was conceived as a JavaScript port of XHP,
Facebook’s version of PHP.
• The first version of React took 17 minutes to render
10,000 DOM elements on 1 Ghz CPU.
• React gained favor at Facebook when it was used to
fix the perpetually broken chat app.
Who the heck uses React?
Facts on Flux
• Flux is not a framework. You can’t download it.
• Flux was designed by Facebook to work with React.
• Flux’s uni-directional dataflow
• You can download lot’s o’ libraries to help you implement Flux such as :
• Flummox
• Alt
• Fluxxor
• Flux This
• MartyJS
• McFly
• Fluxible
• Delorean
• Lux
• Reflux
• OmniscientJS
• Fluxy
• Material Flux
• Flux
The Problem with
Large MVC Web
Applications
Model
Model
Flux Uni-directional Flow
StoreDispatcher
Store
Store
Detailed
Data Flow
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
Demo Time
Yeah, I know
These slides
are horrible.
Here’s a cat
picture to
make it up to
you.
Web API
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
Your WEB API is your server-
side architecture. It can be
SOAP, REST, WebSockets,
whatever.
WEB Utilities
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
A client-side data-layer to
serving as an abstraction
between your WEB API and
Your Action Creators.
Action Creators
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
When new data enters the
system, whether through a
person interacting with the
application or through a web
api call, that data is packaged
into an action — an object
literal containing the new
fields of data and a specific
action type. We often create a
library of helper methods
called action creators that not
only create the action object,
but also pass the action to the
dispatcher.
The Dispatcher
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
The dispatcher is used to
broadcast payloads to
registered callbacks
Stores
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
Stores contain the application
state and logic. Their role is
somewhat similar to a model
in a traditional MVC, but they
manage the state of many
objects — they do not
represent a single record of
data like ORM models do. Nor
are they the same as
Backbone's collections. More
than simply managing a
collection of ORM-style
objects, stores manage the
application state for a
particular domain within the
application.
Views
Store
Dispatcher
React
Views
Action
Creators
WEB API WEB Utils
Actions
User
Interactions
Callbacks
Change
Events
Whew! Now we’re ready to
talk about React.
React + Flux = Joy
(re)Rendering with React – When?
Angular – Dirty Checking
Ember – Observables (get, set)
React– Observables (setState)
(re)Rendering with React – Virtual DOM
var hi = React.createElement( "h1", {className="greet", “Hello World” );
React.render( hi, document.getElementById("example"));
Creating a Virtual DOM Element
Rendering a Virtual DOM element
<div id="example"></div>
DOM
Diff
Patch
<div id="example">
<h1 class="greet">
Hello World
</h1>
</div>
A Smattering of React
Create an element
var elem = React.createElement("h1", null, "Hello World");
Create an element with a Factory
var elem = React.DOM.h1(null, "Hello World");
Render an element
React.render(elem, null, document.body);
React Components
• Represent design elements of your app
• Are re-usable
• Are declarative
• Have two main attributes
• Props – immutable (mostly)
• State –mutable and self-contained
• Can contain other components
• Are oblivious of their parents
JSX – An intuitive way to create components
• Allows you to use XML inside JavaScript.
• Makes your views a cinch to read.
• Is not a templating language.
• Create loops like you do in JavaScript (for, for in, map, forEach, while, etc.)
• Use conditionals like you do in JavaScript (If/else, ternaries)
• Use ES5 or ES6.
• Compiles to JavaScript using JSX Compiler, or Babel.
var HelloWorld = React.createClass({
render: function() { return <h1>Bonjour World</h1> }
});
var HelloWorld = React.createClass({displayName: "HelloWorld",
render: function() {
return React.createElement("h1", null, "Bonjour World");
}
});
A Simple JSX Transform
Props
• Are how you pass data from parent components to child components
• Are immutable (or at least they should be)
• Ensure an uni-directional data flow
• Are how you control an element's attributes like class, id, style, etc.
• Cause React to re-render views when they do change.
Props - Example
const Child = React.createClass({
Render : function(){
return (<li>{this.props.listItem}</li>);
}
});
const Parent = React.createClass({
Render : function(){
var kids = ["a","b","c"].map(
(x,i) => {
return (<Child listItem={x} key={i}/>);
});
return (<ul>{kids}</ul>);
}
});
State
• Is contained and controlled by component.
• Is mutable.
State - Example
const Child = React.createClass({
getInitialState : function(){return {
myText : 'type something'}
},
_changeText : function(event){
this.setState({myText : event.target.value});
},
Render : function(){
return (
<input value={mytext}
onChange={this._changeText} />
);
}
});
Life Cycle First Render
getDefaultProps
getInitialState
componentWillMount
render
componentDidMount
Props Change
componentWillReceiveProps
shouldComponentUpdate
componentWillUpdate
render
componentDidUpdate
State Change
shouldComponentUpdate
componentWIllUpdate
render
componentDidUpdate
Component Unmount
componentWillUnmount
View Controllers
• These are the highest level views.
• Check for changes to the stores here
• Pass all data down to children.
componentDidMount: function () {
MyDosStore.addChangeListener(this._onMyDosChange);
},
componentWillUnmount: function () {
MinionsStore.removeChangeListener(this._onMinionChange);
},
A Word about Routing
Do it!
npm install react-router
Thanks!
Twitter : @johnneed
Blog : johnneed.com
Email : johnneed@johnneed.com
Download the Demo at
https://github.com/johnneed/vtcodecamp20
15
Get Slides at Slide Share.

More Related Content

What's hot (20)

PPTX
Single Page Applications on JavaScript and ASP.NET MVC4
Yuriy Shapovalov
 
PDF
Modern javascript
Kevin Ball
 
PPTX
Single page App
Gaurav Gawande
 
PDF
Modern websites in 2020 and Joomla
George Wilson
 
PDF
FITC - Exploring Art-Directed Responsive Images
Rami Sayar
 
PPTX
How NOT to get lost in the current JavaScript landscape
Radosław Scheibinger
 
PDF
Developing Single Page Apps with Ember.js
Leo Hernandez
 
PDF
Sencha and Spring (Spring 2GX 2013)
Sencha
 
PDF
Frontend as a first class citizen
Marcin Grzywaczewski
 
PDF
Webservices: connecting Joomla! with other programs.
Herman Peeren
 
PDF
Introduction to React and Flux (CodeLabs)
Eueung Mulyana
 
PDF
A Day of REST
Scott Taylor
 
KEY
Capybara-Webkit
bostonrb
 
PPTX
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Mike Schinkel
 
PDF
Meteor Revolution: From DDP to Blaze Reactive Rendering
Massimo Sgrelli
 
PDF
Introduction to Meteor - Worldwide Meteor Day
M A Hossain Tonu
 
PDF
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
PPT
A Tour of Ruby On Rails
David Keener
 
PPTX
Real life cross-platform application development using Xamarin Forms - Frank ...
Codemotion
 
Single Page Applications on JavaScript and ASP.NET MVC4
Yuriy Shapovalov
 
Modern javascript
Kevin Ball
 
Single page App
Gaurav Gawande
 
Modern websites in 2020 and Joomla
George Wilson
 
FITC - Exploring Art-Directed Responsive Images
Rami Sayar
 
How NOT to get lost in the current JavaScript landscape
Radosław Scheibinger
 
Developing Single Page Apps with Ember.js
Leo Hernandez
 
Sencha and Spring (Spring 2GX 2013)
Sencha
 
Frontend as a first class citizen
Marcin Grzywaczewski
 
Webservices: connecting Joomla! with other programs.
Herman Peeren
 
Introduction to React and Flux (CodeLabs)
Eueung Mulyana
 
A Day of REST
Scott Taylor
 
Capybara-Webkit
bostonrb
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Mike Schinkel
 
Meteor Revolution: From DDP to Blaze Reactive Rendering
Massimo Sgrelli
 
Introduction to Meteor - Worldwide Meteor Day
M A Hossain Tonu
 
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
A Tour of Ruby On Rails
David Keener
 
Real life cross-platform application development using Xamarin Forms - Frank ...
Codemotion
 

Similar to React + Flux = Joy (20)

PPTX
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
PPTX
ReactJS Code Impact
Raymond McDermott
 
PDF
The Road To Redux
Jeffrey Sanchez
 
PPTX
ReactJS
Fatih Şimşek
 
PDF
React & Redux
Federico Bond
 
PPTX
reactJS
Syam Santhosh
 
PDF
An Overview of the React Ecosystem
FITC
 
PPSX
React introduction
Kashyap Parmar
 
PDF
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
PPTX
React_Complete.pptx
kamalakantas
 
PPTX
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
PPT
ReactJS.ppt
MOMEKEMKUEFOUETDUREL
 
PPTX
React.js - The Dawn of Virtual DOM
Jimit Shah
 
PPTX
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
zmulani8
 
PDF
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
PDF
Tech Talk on ReactJS
Atlogys Technical Consulting
 
PDF
React Tech Salon
Chenguang ZHANG
 
PPTX
react js training|react js training in mumbai|
programmersclubonlin
 
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
ReactJS Code Impact
Raymond McDermott
 
The Road To Redux
Jeffrey Sanchez
 
React & Redux
Federico Bond
 
reactJS
Syam Santhosh
 
An Overview of the React Ecosystem
FITC
 
React introduction
Kashyap Parmar
 
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
React_Complete.pptx
kamalakantas
 
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
React.js - The Dawn of Virtual DOM
Jimit Shah
 
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
zmulani8
 
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
Tech Talk on ReactJS
Atlogys Technical Consulting
 
React Tech Salon
Chenguang ZHANG
 
react js training|react js training in mumbai|
programmersclubonlin
 
Ad

Recently uploaded (20)

PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Brief History of Python by Learning Python in three hours
adanechb21
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Ad

React + Flux = Joy

  • 1. A New Way to Build Awesome Web Applications John Need Senior UI Developer Twitter : @johnneed Blog : johnneed.com Email : [email protected] + =
  • 2. React + Flux = Joy A View Rendering Engine A Design Pattern A method for building ginormous web applications that retain "Conceptual Simplicity" even as they grow
  • 3. Conceptual Simplicity A model that fits in your head And doesn't change even if your app gets huge
  • 4. A Bit About React • React only renders views. It’s not a SPA framework. • React was started by Jordan Walke, a developer at Facebook in 2011 • Was conceived as a JavaScript port of XHP, Facebook’s version of PHP. • The first version of React took 17 minutes to render 10,000 DOM elements on 1 Ghz CPU. • React gained favor at Facebook when it was used to fix the perpetually broken chat app.
  • 5. Who the heck uses React?
  • 6. Facts on Flux • Flux is not a framework. You can’t download it. • Flux was designed by Facebook to work with React. • Flux’s uni-directional dataflow • You can download lot’s o’ libraries to help you implement Flux such as : • Flummox • Alt • Fluxxor • Flux This • MartyJS • McFly • Fluxible • Delorean • Lux • Reflux • OmniscientJS • Fluxy • Material Flux • Flux
  • 7. The Problem with Large MVC Web Applications Model Model
  • 9. Detailed Data Flow Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events
  • 11. Yeah, I know These slides are horrible. Here’s a cat picture to make it up to you.
  • 12. Web API Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events Your WEB API is your server- side architecture. It can be SOAP, REST, WebSockets, whatever.
  • 13. WEB Utilities Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events A client-side data-layer to serving as an abstraction between your WEB API and Your Action Creators.
  • 14. Action Creators Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events When new data enters the system, whether through a person interacting with the application or through a web api call, that data is packaged into an action — an object literal containing the new fields of data and a specific action type. We often create a library of helper methods called action creators that not only create the action object, but also pass the action to the dispatcher.
  • 15. The Dispatcher Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events The dispatcher is used to broadcast payloads to registered callbacks
  • 16. Stores Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events Stores contain the application state and logic. Their role is somewhat similar to a model in a traditional MVC, but they manage the state of many objects — they do not represent a single record of data like ORM models do. Nor are they the same as Backbone's collections. More than simply managing a collection of ORM-style objects, stores manage the application state for a particular domain within the application.
  • 17. Views Store Dispatcher React Views Action Creators WEB API WEB Utils Actions User Interactions Callbacks Change Events Whew! Now we’re ready to talk about React.
  • 19. (re)Rendering with React – When? Angular – Dirty Checking Ember – Observables (get, set) React– Observables (setState)
  • 20. (re)Rendering with React – Virtual DOM var hi = React.createElement( "h1", {className="greet", “Hello World” ); React.render( hi, document.getElementById("example")); Creating a Virtual DOM Element Rendering a Virtual DOM element <div id="example"></div> DOM Diff Patch <div id="example"> <h1 class="greet"> Hello World </h1> </div>
  • 21. A Smattering of React Create an element var elem = React.createElement("h1", null, "Hello World"); Create an element with a Factory var elem = React.DOM.h1(null, "Hello World"); Render an element React.render(elem, null, document.body);
  • 22. React Components • Represent design elements of your app • Are re-usable • Are declarative • Have two main attributes • Props – immutable (mostly) • State –mutable and self-contained • Can contain other components • Are oblivious of their parents
  • 23. JSX – An intuitive way to create components • Allows you to use XML inside JavaScript. • Makes your views a cinch to read. • Is not a templating language. • Create loops like you do in JavaScript (for, for in, map, forEach, while, etc.) • Use conditionals like you do in JavaScript (If/else, ternaries) • Use ES5 or ES6. • Compiles to JavaScript using JSX Compiler, or Babel.
  • 24. var HelloWorld = React.createClass({ render: function() { return <h1>Bonjour World</h1> } }); var HelloWorld = React.createClass({displayName: "HelloWorld", render: function() { return React.createElement("h1", null, "Bonjour World"); } }); A Simple JSX Transform
  • 25. Props • Are how you pass data from parent components to child components • Are immutable (or at least they should be) • Ensure an uni-directional data flow • Are how you control an element's attributes like class, id, style, etc. • Cause React to re-render views when they do change.
  • 26. Props - Example const Child = React.createClass({ Render : function(){ return (<li>{this.props.listItem}</li>); } }); const Parent = React.createClass({ Render : function(){ var kids = ["a","b","c"].map( (x,i) => { return (<Child listItem={x} key={i}/>); }); return (<ul>{kids}</ul>); } });
  • 27. State • Is contained and controlled by component. • Is mutable.
  • 28. State - Example const Child = React.createClass({ getInitialState : function(){return { myText : 'type something'} }, _changeText : function(event){ this.setState({myText : event.target.value}); }, Render : function(){ return ( <input value={mytext} onChange={this._changeText} /> ); } });
  • 29. Life Cycle First Render getDefaultProps getInitialState componentWillMount render componentDidMount Props Change componentWillReceiveProps shouldComponentUpdate componentWillUpdate render componentDidUpdate State Change shouldComponentUpdate componentWIllUpdate render componentDidUpdate Component Unmount componentWillUnmount
  • 30. View Controllers • These are the highest level views. • Check for changes to the stores here • Pass all data down to children. componentDidMount: function () { MyDosStore.addChangeListener(this._onMyDosChange); }, componentWillUnmount: function () { MinionsStore.removeChangeListener(this._onMinionChange); },
  • 31. A Word about Routing Do it! npm install react-router
  • 32. Thanks! Twitter : @johnneed Blog : johnneed.com Email : [email protected] Download the Demo at https://github.com/johnneed/vtcodecamp20 15 Get Slides at Slide Share.