SlideShare a Scribd company logo
ReactJS
Ben Newman (@benjamn)
Paul O’Shannessy (@zpao)
React
reactjs.org
Components
<div>, <span>
<ActionButton>, <Counter>
Anatomy of a Component
<ActionButton text="Book flight" onAction={someFunc} />
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
!
!
!
!
!
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
!
!
!
!
!
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton">	
<span>button text</span>	
</button>	
);	
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton">	
<span>{this.props.text}</span>	
</button>	
);	
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton" onClick={this.props.onAction}>	
<span>{this.props.text}</span>	
</button>	
);	
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton" onClick={this.props.onAction}>	
<span>{this.props.text}</span>	
</button>	
);	
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton" onClick={this.props.onAction}>	
<span>{this.props.text.toUpperCase()}</span>	
</button>	
);	
}	
});
<ActionButton text="Book flight" onAction={someFunc} />
var ActionButton = React.createClass({	
render: function() {	
return (	
<button class="ActionButton" onClick={this.props.onAction}>	
<span>{this.props.text}</span>	
</button>	
);	
}	
});
<Counter initialCount={4} />
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
What makes React different?
1. Components, not templates
2. Re-render on update
3. Virtual DOM (and events)
ReactJS
ReactJS
1. Components, not templates
Separation of
concerns:
!
Reduce coupling, increase cohesion.
Coupling is:
“The degree to which each program
module relies on each of the other
modules.”
http://en.wikipedia.org/wiki/Coupling_(computer_science)
Cohesion is:
“The degree to which elements of a
module belong together.”
http://en.wikipedia.org/wiki/Cohesion_(computer_science)
“View model” tightly
couples template to
display logic.
[{“price”: “7.99”, “product”: “Back
scratcher”, “tableRowColor”: “rgba(0, 0, 0,
0.5)”}]
Templates separate
technologies, not
concerns
React components are loosely
coupled and highly cohesive
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
2. Re-render on every change
<Counter initialCount={4} />
var Counter = React.createClass({	
getInitialState: function() {	
return {count: this.props.initialCount};	
},	
addToCount: function(delta) {	
this.setState({count: this.state.count + delta})	
},	
render: function() {	
return (	
<div>	
<h3>Count: {this.state.count}</h3>	
<ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} />	
<ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} />	
</div>	
);	
}	
});
- no DOM mutations
- no bindings between data and DOM
- in general, way less shit to think about
Best analogy: Website from 1994
Data changing over time is the
root of all evil.
Re-rendering on
every change makes
things simple.
Every place data is displayed is guaranteed
to be up-to-date.
No magical data binding.
Re-rendering on
every change makes
things simple.
No model dirty checking.
Re-rendering on
every change makes
things simple.
No more explicit DOM operations –
everything is declarative.
Re-rendering on
every change makes
things simple.
3. Virtual DOM
Won’t rerendering be as slow as
molasses?!
React has a virtual DOM (and
events system).
Optimized for performance and
memory footprint
On every update…
• React builds a new virtual DOM
subtree
• …diffs it with the old one
• …computes the minimal set of DOM
mutations and puts them in a queue
• …and batch executes all updates
It’s fast!
Because the DOM is slow!
It’s fast!
Computes minimal DOM operations
It’s fast!
Batched reads and writes for optimal DOM
performance
It’s fast!
Usually faster than manual DOM
operations
It’s fast!
Automatic top-level event delegation (with
cross-browser HTML5 events)
It’s fast!
Can do all this at 60fps, even in a (non-JIT)
UIWebView on the iPhone.
Why Should YOU Use React?
• Can be used for parts of your application
• Plays well with other libraries and technologies

(meteor, rails, node)
• Components allow you to split work easily
Learn more and get involved
• http://reactjs.org
• #reactjs on Freenode IRC
• reactjs on Google Groups
• www.facebook.com/careers
More Links
• react-meteor: https://github.com/benjamn/react-meteor
• <ActionButton> demo: http://jsfiddle.net/zpao/EFhy4/
• <Clicker> demo: http://jsfiddle.net/zpao/fk5Pc/
ReactJS
Ad

More Related Content

What's hot (20)

React.js & Om: A hands-on walkthrough of better ways to build web UIs
React.js & Om: A hands-on walkthrough of better ways to build web UIsReact.js & Om: A hands-on walkthrough of better ways to build web UIs
React.js & Om: A hands-on walkthrough of better ways to build web UIs
Adam Solove
 
React
React React
React
중운 박
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
Ali Sa'o
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
Maksym Petruk
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
Glib Kechyn
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
Domenic Denicola
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
nishasowdri
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
Binary Studio
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
Zhihao Li
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
Eldar Djafarov
 
React & redux
React & reduxReact & redux
React & redux
Cédric Hartland
 
Redux vs Alt
Redux vs AltRedux vs Alt
Redux vs Alt
Uldis Sturms
 
Avoiding callback hell with promises
Avoiding callback hell with promisesAvoiding callback hell with promises
Avoiding callback hell with promises
TorontoNodeJS
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
Vinícius Ribeiro
 
React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016
Simon Sturmer
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
Tomasz Bak
 
Intro to ReactJS
Intro to ReactJSIntro to ReactJS
Intro to ReactJS
Harvard Web Working Group
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
Eugene Zharkov
 
Promise pattern
Promise patternPromise pattern
Promise pattern
Sebastiaan Deckers
 
React.js & Om: A hands-on walkthrough of better ways to build web UIs
React.js & Om: A hands-on walkthrough of better ways to build web UIsReact.js & Om: A hands-on walkthrough of better ways to build web UIs
React.js & Om: A hands-on walkthrough of better ways to build web UIs
Adam Solove
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
Ali Sa'o
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
Maksym Petruk
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
Glib Kechyn
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
nishasowdri
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
Binary Studio
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
Zhihao Li
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
Eldar Djafarov
 
Avoiding callback hell with promises
Avoiding callback hell with promisesAvoiding callback hell with promises
Avoiding callback hell with promises
TorontoNodeJS
 
React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016
Simon Sturmer
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
Tomasz Bak
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
Eugene Zharkov
 

Viewers also liked (20)

ReactJs
ReactJsReactJs
ReactJs
LearningTech
 
ReactJS | 서버와 클라이어트에서 동시에 사용하는
ReactJS | 서버와 클라이어트에서 동시에 사용하는ReactJS | 서버와 클라이어트에서 동시에 사용하는
ReactJS | 서버와 클라이어트에서 동시에 사용하는
Taegon Kim
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014
StampedeCon
 
Probability with Cards
Probability with CardsProbability with Cards
Probability with Cards
ianrhunter
 
Unity 5: First-Person Tutorial
Unity 5: First-Person TutorialUnity 5: First-Person Tutorial
Unity 5: First-Person Tutorial
Shahed Chowdhuri
 
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
DataStax
 
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Kai Wähner
 
Elon Musk and his innovations
Elon Musk and his innovationsElon Musk and his innovations
Elon Musk and his innovations
Rohan Bharaj
 
19 Mini Productivity Hacks For A Simple (But An Awesome) Day
19 Mini Productivity Hacks For A Simple (But An Awesome) Day19 Mini Productivity Hacks For A Simple (But An Awesome) Day
19 Mini Productivity Hacks For A Simple (But An Awesome) Day
Thomas Oppong
 
Inside BCG's Smart Simplicity Approach
Inside BCG's Smart Simplicity ApproachInside BCG's Smart Simplicity Approach
Inside BCG's Smart Simplicity Approach
Boston Consulting Group
 
Entrepreneur Elon musk
Entrepreneur   Elon muskEntrepreneur   Elon musk
Entrepreneur Elon musk
Shashank Tiwari
 
Bill gates powerpoint
Bill gates powerpointBill gates powerpoint
Bill gates powerpoint
masonwilson1
 
Leadership by Elon Musk with Tesla and SpaceX
Leadership by Elon Musk with Tesla and SpaceXLeadership by Elon Musk with Tesla and SpaceX
Leadership by Elon Musk with Tesla and SpaceX
Saptu Ray
 
Bill gates leadership & personality traits
Bill gates leadership & personality traitsBill gates leadership & personality traits
Bill gates leadership & personality traits
Akhil Pillai
 
Elon Musk- Visionary, Leader, Entrepreneur
Elon Musk- Visionary, Leader, EntrepreneurElon Musk- Visionary, Leader, Entrepreneur
Elon Musk- Visionary, Leader, Entrepreneur
Muhtasim Sarowat Rayed
 
Smart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challengeSmart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challenge
Boston Consulting Group
 
Datomic
DatomicDatomic
Datomic
Jordan Leigh
 
Datomic
DatomicDatomic
Datomic
Christophe Marchal
 
Datomic
DatomicDatomic
Datomic
jperkelens
 
Waldorf Education
Waldorf EducationWaldorf Education
Waldorf Education
xMerodi
 
ReactJS | 서버와 클라이어트에서 동시에 사용하는
ReactJS | 서버와 클라이어트에서 동시에 사용하는ReactJS | 서버와 클라이어트에서 동시에 사용하는
ReactJS | 서버와 클라이어트에서 동시에 사용하는
Taegon Kim
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014
StampedeCon
 
Probability with Cards
Probability with CardsProbability with Cards
Probability with Cards
ianrhunter
 
Unity 5: First-Person Tutorial
Unity 5: First-Person TutorialUnity 5: First-Person Tutorial
Unity 5: First-Person Tutorial
Shahed Chowdhuri
 
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
Fast, In-Memory SQL on Apache Cassandra with Apache Ignite (Rachel Pedreschi,...
DataStax
 
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Real World Use Cases and Success Stories for In-Memory Data Grids (TIBCO Acti...
Kai Wähner
 
Elon Musk and his innovations
Elon Musk and his innovationsElon Musk and his innovations
Elon Musk and his innovations
Rohan Bharaj
 
19 Mini Productivity Hacks For A Simple (But An Awesome) Day
19 Mini Productivity Hacks For A Simple (But An Awesome) Day19 Mini Productivity Hacks For A Simple (But An Awesome) Day
19 Mini Productivity Hacks For A Simple (But An Awesome) Day
Thomas Oppong
 
Bill gates powerpoint
Bill gates powerpointBill gates powerpoint
Bill gates powerpoint
masonwilson1
 
Leadership by Elon Musk with Tesla and SpaceX
Leadership by Elon Musk with Tesla and SpaceXLeadership by Elon Musk with Tesla and SpaceX
Leadership by Elon Musk with Tesla and SpaceX
Saptu Ray
 
Bill gates leadership & personality traits
Bill gates leadership & personality traitsBill gates leadership & personality traits
Bill gates leadership & personality traits
Akhil Pillai
 
Elon Musk- Visionary, Leader, Entrepreneur
Elon Musk- Visionary, Leader, EntrepreneurElon Musk- Visionary, Leader, Entrepreneur
Elon Musk- Visionary, Leader, Entrepreneur
Muhtasim Sarowat Rayed
 
Smart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challengeSmart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challenge
Boston Consulting Group
 
Waldorf Education
Waldorf EducationWaldorf Education
Waldorf Education
xMerodi
 
Ad

Similar to ReactJS (20)

React 101
React 101React 101
React 101
Casear Chu
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
Boris Dinkevich
 
Full Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R StackFull Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R Stack
Scott Persinger
 
Road to react hooks
Road to react hooksRoad to react hooks
Road to react hooks
Younes (omar) Meliani
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
Ken Wheeler
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
Adam L Barrett
 
Introduction to React and MobX
Introduction to React and MobXIntroduction to React and MobX
Introduction to React and MobX
Anjali Chawla
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
Ignacio Martín
 
How do we use hooks
How do we use hooksHow do we use hooks
How do we use hooks
Jim Liu
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
Ben Lesh
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extension
Hendy Irawan
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
BOSC Tech Labs
 
Client Web
Client WebClient Web
Client Web
Markiyan Matsekh
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
Greg Bergé
 
Redux js
Redux jsRedux js
Redux js
Nils Petersohn
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Full Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R StackFull Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R Stack
Scott Persinger
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
Ken Wheeler
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
Adam L Barrett
 
Introduction to React and MobX
Introduction to React and MobXIntroduction to React and MobX
Introduction to React and MobX
Anjali Chawla
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
How do we use hooks
How do we use hooksHow do we use hooks
How do we use hooks
Jim Liu
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
Ben Lesh
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extension
Hendy Irawan
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
BOSC Tech Labs
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
Greg Bergé
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Ad

More from Kamlesh Singh (8)

Angular js book
Angular js bookAngular js book
Angular js book
Kamlesh Singh
 
Smart machines
Smart machinesSmart machines
Smart machines
Kamlesh Singh
 
Spring roo-docs
Spring roo-docsSpring roo-docs
Spring roo-docs
Kamlesh Singh
 
Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
Kamlesh Singh
 
Oops Concept Java
Oops Concept JavaOops Concept Java
Oops Concept Java
Kamlesh Singh
 
Java Basic day-2
Java Basic day-2Java Basic day-2
Java Basic day-2
Kamlesh Singh
 
Java Basic day-1
Java Basic day-1Java Basic day-1
Java Basic day-1
Kamlesh Singh
 
Jvm
JvmJvm
Jvm
Kamlesh Singh
 

Recently uploaded (20)

To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 

ReactJS

  • 2. Ben Newman (@benjamn) Paul O’Shannessy (@zpao) React reactjs.org
  • 4. Anatomy of a Component
  • 5. <ActionButton text="Book flight" onAction={someFunc} />
  • 6. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { ! ! ! ! ! } });
  • 7. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { ! ! ! ! ! } });
  • 8. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton"> <span>button text</span> </button> ); } });
  • 9. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton"> <span>{this.props.text}</span> </button> ); } });
  • 10. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton" onClick={this.props.onAction}> <span>{this.props.text}</span> </button> ); } });
  • 11. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton" onClick={this.props.onAction}> <span>{this.props.text}</span> </button> ); } });
  • 12. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton" onClick={this.props.onAction}> <span>{this.props.text.toUpperCase()}</span> </button> ); } });
  • 13. <ActionButton text="Book flight" onAction={someFunc} /> var ActionButton = React.createClass({ render: function() { return ( <button class="ActionButton" onClick={this.props.onAction}> <span>{this.props.text}</span> </button> ); } });
  • 15. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 16. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 17. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 18. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 19. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 20. What makes React different?
  • 21. 1. Components, not templates 2. Re-render on update 3. Virtual DOM (and events)
  • 24. 1. Components, not templates
  • 26. Coupling is: “The degree to which each program module relies on each of the other modules.” http://en.wikipedia.org/wiki/Coupling_(computer_science)
  • 27. Cohesion is: “The degree to which elements of a module belong together.” http://en.wikipedia.org/wiki/Cohesion_(computer_science)
  • 28. “View model” tightly couples template to display logic. [{“price”: “7.99”, “product”: “Back scratcher”, “tableRowColor”: “rgba(0, 0, 0, 0.5)”}]
  • 30. React components are loosely coupled and highly cohesive
  • 31. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } });
  • 32. 2. Re-render on every change
  • 33. <Counter initialCount={4} /> var Counter = React.createClass({ getInitialState: function() { return {count: this.props.initialCount}; }, addToCount: function(delta) { this.setState({count: this.state.count + delta}) }, render: function() { return ( <div> <h3>Count: {this.state.count}</h3> <ActionButton text="+1" onAction={this.addToCount.bind(this, 1)} /> <ActionButton text="-1" onAction={this.addToCount.bind(this, -1)} /> </div> ); } }); - no DOM mutations - no bindings between data and DOM - in general, way less shit to think about
  • 35. Data changing over time is the root of all evil.
  • 36. Re-rendering on every change makes things simple. Every place data is displayed is guaranteed to be up-to-date.
  • 37. No magical data binding. Re-rendering on every change makes things simple.
  • 38. No model dirty checking. Re-rendering on every change makes things simple.
  • 39. No more explicit DOM operations – everything is declarative. Re-rendering on every change makes things simple.
  • 41. Won’t rerendering be as slow as molasses?!
  • 42. React has a virtual DOM (and events system). Optimized for performance and memory footprint
  • 43. On every update… • React builds a new virtual DOM subtree • …diffs it with the old one • …computes the minimal set of DOM mutations and puts them in a queue • …and batch executes all updates
  • 44. It’s fast! Because the DOM is slow!
  • 46. It’s fast! Batched reads and writes for optimal DOM performance
  • 47. It’s fast! Usually faster than manual DOM operations
  • 48. It’s fast! Automatic top-level event delegation (with cross-browser HTML5 events)
  • 49. It’s fast! Can do all this at 60fps, even in a (non-JIT) UIWebView on the iPhone.
  • 50. Why Should YOU Use React? • Can be used for parts of your application • Plays well with other libraries and technologies
 (meteor, rails, node) • Components allow you to split work easily
  • 51. Learn more and get involved • http://reactjs.org • #reactjs on Freenode IRC • reactjs on Google Groups • www.facebook.com/careers
  • 52. More Links • react-meteor: https://github.com/benjamn/react-meteor • <ActionButton> demo: http://jsfiddle.net/zpao/EFhy4/ • <Clicker> demo: http://jsfiddle.net/zpao/fk5Pc/