SlideShare ist ein Scribd-Unternehmen logo
1 von 70
Downloaden Sie, um offline zu lesen
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYOND
THE BROWSER
REACT.JS: BEYON
THE BROWSER
REACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYO
REACT.JS: BEYOND
THE BROWSER
@gabescholz
“just remember I am
going after you”
- Godfrey Chan,
wannabe Thought Leader
“the whole reason I am
doing the talk is to go
after you”
JAVASCRIPT
“… the latest and
greatest JavaScript
framework comes around
every sixteen minutes.”
- Allen Pike, King of VanJS
http://www.allenpike.com/2015/javascript-framework-fatigue/
“Helping you select an
MV* framework”
!
(with 64 different choices!!)
http://todomvc.com/
CHOICE PARALYSIS
/noun/
!
!
the state of being unable to select a proper
JavaScript framework
!
“I literally can’t feel my legs due to this
choice paralysis.”
http://www.sitepoint.com/drowning-in-tools-web-development-industry/
“… people come from a
wide variety of
backgrounds, and have a
wide variety of goals.
This constant inflow of
new ideas and interests
has made the JavaScript
community unusually
diverse.”
http://www.allenpike.com/2015/javascript-framework-fatigue/
FOAM“FOAM is a full-stack, reactive,
deeply MVC metaprogramming
Javascript framework.”
<meta name=“description” … />
@gabescholz
e
2. “Learn once,
Write anywhere”
1. Why React?
😍 Everything is JavaScript
<!-- template.html -->
!
<weather-widget forecast=“forecast”>
<weather-link href=“http://weather.ca”>
sherr, bud
</weather-link>
</weather-widget>
// component.js
!
<WeatherWidget forecast={forecast}>
<WeatherLink href=“http://weather.ca”>
sherr, bud
</WeatherLink>
</WeatherWidget>
// component.js
!
React.createElement(WeatherWidget,
{ forecast: forecast },
React.createElement(WeatherLink,
{ href: “http://weather.ca” },
“sherr, bud”
)
)
Dat JSX, tho
// component.js
!
React.createElement(“div”, {},
React.createElement(“a”,
{ href: “http://weather.ca” },
“sherr, bud”
)
)
Dat JSX, tho
FEELS GOOD MAN
var WeatherApp = React.createClass({
getInitialState () {
return {
forecast: ‘sunny’
};
},


render () {
var forecast = this.state.forecast;
!
return (
<WeatherWidget forecast={forecast}>
<WeatherLink href=“http://weather.ca”>
sherr, bud
</WeatherLink>
</WeatherWidget>
)
}
});
😁 Virtual DOM
+
Diffing
renderA: <div />
renderB: <span />
[removeNode <div />],
[insertNode <span />]
renderA: <PuttyPatrol />
renderB: <Goldar />
[removeNode <PuttyPatrol />],
[insertNode <Goldar />]
renderA: <div id="ahHhhhHh" />
renderB: <div id=“after-10000-years-im-free” />
[replaceAttribute id "after-10000-years-im-free"]
😁 One-way
Reactive Rendering
STATE vs PROPS
in TWO MINUTES
var Parent = React.createClass({
// ...
render () {
return (
<div>
<Son name={this.state.sonsName} />
<Daughter name={this.state.daughtersName} />
</div>
);
}
});
!
var Daughter = React.createClass({
// ...
render () {
return (
<div>
<div>{this.props.name}</div>
<div>{this.state.favouriteColor}</div>
<Dog name=`Mini ${this.props.name}` />
</div>
);
}
});
var Parent = React.createClass({
// …
!
updateToLaquesha () {
this.setState({ daughtersName: “Laquesha” });
},
!
render () {
return (
<div>
<button onClick={this.updateToLaquesha} />
<Son name={this.state.sonsName} />
<Daughter name={this.state.daughtersName} />
</div>
);
}
});
Going beyond the DOM
React Canvas
Created by Flipboard
60 fps on mobile browsers
Last commit ~1 week after React
Native released publicly
<Surface>
<Layer>
<Text
style={{
fontFace: ‘Calibri’, fontSize: ‘40pt’
}}>{this.state.text}</Text>
</Layer>
</Surface>
`
var context = canvas.getContext(‘2d’);
context.font = '40pt Calibri';
context.fillText(text, 0, 0);
React Native
Created by Facebook
All of your business logic is
written and runs in JavaScript
using JavaScriptCore on iOS
UI Kit instead of DOM Nodes
<div>
<img src=“http://i.imgur.com/OBB7tLg.gif” />
<input type=“text” />
<span>sherrr, bud</span>
</div>
<View>
<Image source={{uri: “http://i.imgur.com/
OBB7tLg.gif”}} />
<TextInput />
<Text>sherrr, bud</Text>
</View>
React Native
*style required but not included
ReactGibbon
Created by Netflix
Runs on their Gibbon
platform
Renders JSON instead of
DOM
`
I SHOULD PUT REACT ON SOMETHINGI SHOULD PUT REACT ON SOMETHING
https://github.com/garbles/react-pebble-demo
var card = UI.Card({
title: “Fetching movies list”,
subtitle: “Just a minute..”,
body: “1 sec..”
});
card.show();
// ...
card.hide();
!
!
!
!
!
!
!
<Card
title=“Fetching movies list”
subtitle=“Just a minute..”
body=“1 sec..” />
var list = UI.List();
list.sections([{}]);
// for every item
var items = list.items(0);
list.items(0, items.concat(item));
!
list.show();
// ...
list.hide();
!
!
!
!
!
<List onSelect={this.handleSelect}>
<Item title=“..” ... />

<Item title=“..” ... />
<Item title=“..” ... />
<Item title=“..” ... />
</List>
var App = React.createClass({
getInitialState () { },
selectItem (item) { },
!
componentDidMount () {
ajax(apiUrl, (response) => {
this.setState({ movies: response[1].movies }) });
},
!
render () {
var movies = this.state.movies.map( movie => {
return (<Item title={movie.title} data={movie} />);
});
!
if (movies.length) {
return <List onSelect={this.selectItem}>{movies}</List>;
} else {
return <Card ... />;
}
}
});
var App = React.createClass({
getInitialState () { return { movies: [] } },
selectItem (item) { },
!
componentDidMount () {
ajax(apiUrl, (response) => {
this.setState({ movies: response[1].movies }) });
},
!
render () {
var movies = this.state.movies.map( movie => {
return (<Item title={movie.title} data={movie} />);
});
!
if (movies.length) {
return <List onSelect={this.selectItem}>{movies}</List>;
} else {
return <Card ... />;
}
}
});
var App = React.createClass({
getInitialState () { },
selectItem (item) { },
!
componentDidMount () {
ajax(apiUrl, (response) => {
this.setState({ movies: response[1].movies }) });
},
!
render () {
var movies = this.state.movies.map( movie => {
return (<Item title={movie.title} data={movie} />);
});
!
if (movies.length) {
return <List onSelect={this.selectItem}>{movies}</List>;
} else {
return <Card ... />;
}
}
});
var App = React.createClass({
getInitialState () { },
selectItem (item) { },
!
componentDidMount () {
ajax(apiUrl, (response) => {
this.setState({ movies: response[1].movies }) });
},
!
render () {
var movies = this.state.movies.map( movie => {
return (<Item title={movie.title} data={movie} />);
});
!
if (movies.length) {
return <List onSelect={this.selectItem}>{movies}</List>;
} else {
return <Card ... />;
}
}
});
😛 Becoming a React trickster
function createComponent(name) {
!
var CustomComponent = function(props) {
this.node = new PebbleNode();
this.subscriptions = null;
this.listeners = null;
this._mountImage = null;
this._renderedChildren = null;
};
!
CustomComponent.displayName = name;
!
for (var i = 1, l = arguments.length; i < l; i++) {
assign(CustomComponent.prototype, arguments[i]);
}
!
return CustomComponent;
}
function createComponent(name) {
!
var CustomComponent = function(props) {
this.node = new PebbleNode();
this.subscriptions = null;
this.listeners = null;
this._mountImage = null;
this._renderedChildren = null;
};
!
CustomComponent.displayName = name;
!
for (var i = 1, l = arguments.length; i < l; i++) {
assign(CustomComponent.prototype, arguments[i]);
}
!
return CustomComponent;
}
function createComponent(name) {
!
var CustomComponent = function(props) {
this.node = new PebbleNode();
this.subscriptions = null;
this.listeners = null;
this._mountImage = null;
this._renderedChildren = null;
};
!
CustomComponent.displayName = name;
!
for (var i = 1, l = arguments.length; i < l; i++) {
assign(CustomComponent.prototype, arguments[i]);
}
!
return CustomComponent;
}
var Card = createComponent(
‘Card’,
NodeMixin,
ComponentMixin,
...,
{ /* additional behaviours */ }
);
!
var PebbleApp = React.createClass({
render () {
return (
<Card title=“Hello World!”/>
);
}
});
!
renderPebble(<PebbleApp />);
var NodeMixin = {
putEventListener (...) { /* ... */ },
handleEvent (...) { /* ... */ },
destroyEventListeners (...) { /* ... */ },
applyNodeProps (...) { /* ... */ }
};
!
var ContainerMixin = assign({}, ReactMultiChild.Mixin, {
moveChild (...) { /* ... */ },
createChild (...) { /* ... */ },
replaceChild (...) { /* ... */ },
updateChildrenAtRoot (...) { /* ... */ },
mountAndInjectChildren (...) { /* ... */ }
});
!
// per component
{
construct (...) { /* ... */ },
mountComponent (...) { /* ... */ },
unmountComponent (...) { /* ... */ },
receiveComponent (...) { /* ... */ }
};
var Card = createComponent(‘Card’, NodeMixin, {
construct (element) {
this._currentElement = element;
this.__instance = new UI.Card();
},
mountComponent (rootID, transaction, context) {
var props = this._currentElement.props;
this._rootNodeID = rootID;
!
this.__instance.prop(props);
this.__instance.show();
!
return this.node;
},
unmountComponent () {
this.__instance.hide();
},
receiveComponent (element) {
this._currentElement = element;
this.__instance.prop(element.props);
}
});
var Card = createComponent(‘Card’, NodeMixin, {
construct (element) {
this._currentElement = element;
this.__instance = new UI.Card();
},
mountComponent (rootID, transaction, context) {
var props = this._currentElement.props;
this._rootNodeID = rootID;
!
this.__instance.prop(props);
this.__instance.show();
!
return this.node;
},
unmountComponent () {
this.__instance.hide();
},
receiveComponent (element) {
this._currentElement = element;
this.__instance.prop(element.props);
}
});
var Card = createComponent(‘Card’, NodeMixin, {
construct (element) {
this._currentElement = element;
this.__instance = new UI.Card();
},
mountComponent (rootID, transaction, context) {
var props = this._currentElement.props;
this._rootNodeID = rootID;
!
this.__instance.prop(props);
this.__instance.show();
!
return this.node;
},
unmountComponent () {
this.__instance.hide();
},
receiveComponent (element) {
this._currentElement = element;
this.__instance.prop(element.props);
}
});
var Card = createComponent(‘Card’, NodeMixin, {
construct (element) {
this._currentElement = element;
this.__instance = new UI.Card();
},
mountComponent (rootID, transaction, context) {
var props = this._currentElement.props;
this._rootNodeID = rootID;
!
this.__instance.prop(props);
this.__instance.show();
!
return this.node;
},
unmountComponent () {
this.__instance.hide();
},
receiveComponent (element) {
this._currentElement = element;
this.__instance.prop(element.props);
}
});
var Card = createComponent(‘Card’, NodeMixin, {
construct (element) {
this._currentElement = element;
this.__instance = new UI.Card();
},
mountComponent (rootID, transaction, context) {
var props = this._currentElement.props;
this._rootNodeID = rootID;
!
this.__instance.prop(props);
this.__instance.show();
!
return this.node;
},
unmountComponent () {
this.__instance.hide();
},
receiveComponent (element) {
this._currentElement = element;
this.__instance.prop(element.props);
}
});
Resources:
!
https://docs.google.com/presentation/d/1afMLTCpRxhJpurQ97VBHCZkLbR1TEsRnd3yyxuSQ5YY/edit#slide=id.g380053cce_179
!
https://fivejs.codeschool.com/episodes/72-episode-65-march-5th-2015/stories/463-framework-fatigue
!
http://www.sitepoint.com/drowning-in-tools-web-development-industry/
!
http://www.allenpike.com/2015/javascript-framework-fatigue/
!
http://www.todomvc.com
!
Prior Art:
!
https://github.com/reactjs/react-art
!
https://github.com/Flipboard/react-canvas
!
https://github.com/facebook/react
!
https://github.com/facebook/react-native
THANKSTHANKSTHANKSTHANKSTHANKSTHANKSTHANKSTHANKSTHANKSTHANKSTHANKS

Weitere ähnliche Inhalte

Was ist angesagt?

Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux ApplicaitonsStrategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitonsgarbles
 
React.js workshop by tech47.in
React.js workshop by tech47.inReact.js workshop by tech47.in
React.js workshop by tech47.inJaikant Kumaran
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConRafael Dohms
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureGarann Means
 
Simplifying JavaScript Projects with ReactJS
Simplifying JavaScript Projects with ReactJSSimplifying JavaScript Projects with ReactJS
Simplifying JavaScript Projects with ReactJSKevin Dangoor
 
JQuery In Rails
JQuery In RailsJQuery In Rails
JQuery In RailsLouie Zhao
 
Final tagless and cats mtl
Final tagless and cats mtl Final tagless and cats mtl
Final tagless and cats mtl Alexander Zaidel
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptDarren Mothersele
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryRebecca Murphey
 
OOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonOOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonJohn Hann
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)Jeff Eaton
 

Was ist angesagt? (20)

Strategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux ApplicaitonsStrategies for Mitigating Complexity in React Based Redux Applicaitons
Strategies for Mitigating Complexity in React Based Redux Applicaitons
 
React.js workshop by tech47.in
React.js workshop by tech47.inReact.js workshop by tech47.in
React.js workshop by tech47.in
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
BVJS
BVJSBVJS
BVJS
 
Jquery examples
Jquery examplesJquery examples
Jquery examples
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer Architecture
 
Simplifying JavaScript Projects with ReactJS
Simplifying JavaScript Projects with ReactJSSimplifying JavaScript Projects with ReactJS
Simplifying JavaScript Projects with ReactJS
 
JQuery In Rails
JQuery In RailsJQuery In Rails
JQuery In Rails
 
Coding website
Coding websiteCoding website
Coding website
 
Final tagless and cats mtl
Final tagless and cats mtl Final tagless and cats mtl
Final tagless and cats mtl
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQuery
 
YUI 3
YUI 3YUI 3
YUI 3
 
I regret nothing
I regret nothingI regret nothing
I regret nothing
 
OOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonOOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon Boston
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
 
Build your own entity with Drupal
Build your own entity with DrupalBuild your own entity with Drupal
Build your own entity with Drupal
 

Andere mochten auch

Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopMatthew Hayes
 
Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopMatthew Hayes
 
Enforcing Your Code of Conduct: effective incident response
Enforcing Your Code of Conduct: effective incident responseEnforcing Your Code of Conduct: effective incident response
Enforcing Your Code of Conduct: effective incident responseAudrey Eschright
 
Apache Mesos at Twitter (Texas LinuxFest 2014)
Apache Mesos at Twitter (Texas LinuxFest 2014)Apache Mesos at Twitter (Texas LinuxFest 2014)
Apache Mesos at Twitter (Texas LinuxFest 2014)Chris Aniszczyk
 
Keynote: Apache HBase at Yahoo! Scale
Keynote: Apache HBase at Yahoo! ScaleKeynote: Apache HBase at Yahoo! Scale
Keynote: Apache HBase at Yahoo! ScaleHBaseCon
 
What the F**K is Social Media: One Year Later
What the F**K is Social Media: One Year LaterWhat the F**K is Social Media: One Year Later
What the F**K is Social Media: One Year LaterMartafy!
 
Adobe Digital Insights: Mobile Landscape A Moving Target
Adobe Digital Insights: Mobile Landscape A Moving TargetAdobe Digital Insights: Mobile Landscape A Moving Target
Adobe Digital Insights: Mobile Landscape A Moving TargetAdobe
 
Hw09 Practical HBase Getting The Most From Your H Base Install
Hw09   Practical HBase  Getting The Most From Your H Base InstallHw09   Practical HBase  Getting The Most From Your H Base Install
Hw09 Practical HBase Getting The Most From Your H Base InstallCloudera, Inc.
 
Fostering a Startup and Innovation Ecosystem
Fostering a Startup and Innovation EcosystemFostering a Startup and Innovation Ecosystem
Fostering a Startup and Innovation EcosystemTechstars
 
Chicago Data Summit: Apache HBase: An Introduction
Chicago Data Summit: Apache HBase: An IntroductionChicago Data Summit: Apache HBase: An Introduction
Chicago Data Summit: Apache HBase: An IntroductionCloudera, Inc.
 
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersCloudera, Inc.
 

Andere mochten auch (12)

Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on Hadoop
 
Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on Hadoop
 
Danger Of Free
Danger Of FreeDanger Of Free
Danger Of Free
 
Enforcing Your Code of Conduct: effective incident response
Enforcing Your Code of Conduct: effective incident responseEnforcing Your Code of Conduct: effective incident response
Enforcing Your Code of Conduct: effective incident response
 
Apache Mesos at Twitter (Texas LinuxFest 2014)
Apache Mesos at Twitter (Texas LinuxFest 2014)Apache Mesos at Twitter (Texas LinuxFest 2014)
Apache Mesos at Twitter (Texas LinuxFest 2014)
 
Keynote: Apache HBase at Yahoo! Scale
Keynote: Apache HBase at Yahoo! ScaleKeynote: Apache HBase at Yahoo! Scale
Keynote: Apache HBase at Yahoo! Scale
 
What the F**K is Social Media: One Year Later
What the F**K is Social Media: One Year LaterWhat the F**K is Social Media: One Year Later
What the F**K is Social Media: One Year Later
 
Adobe Digital Insights: Mobile Landscape A Moving Target
Adobe Digital Insights: Mobile Landscape A Moving TargetAdobe Digital Insights: Mobile Landscape A Moving Target
Adobe Digital Insights: Mobile Landscape A Moving Target
 
Hw09 Practical HBase Getting The Most From Your H Base Install
Hw09   Practical HBase  Getting The Most From Your H Base InstallHw09   Practical HBase  Getting The Most From Your H Base Install
Hw09 Practical HBase Getting The Most From Your H Base Install
 
Fostering a Startup and Innovation Ecosystem
Fostering a Startup and Innovation EcosystemFostering a Startup and Innovation Ecosystem
Fostering a Startup and Innovation Ecosystem
 
Chicago Data Summit: Apache HBase: An Introduction
Chicago Data Summit: Apache HBase: An IntroductionChicago Data Summit: Apache HBase: An Introduction
Chicago Data Summit: Apache HBase: An Introduction
 
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
 

Ähnlich wie React.js: Beyond the Browser

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 senseEldar Djafarov
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgetsvelveeta_512
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JSFestUA
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB jhchabran
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
Backbone js
Backbone jsBackbone js
Backbone jsrstankov
 
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)indeedeng
 
Practical Event Sourcing
Practical Event SourcingPractical Event Sourcing
Practical Event SourcingMathias Verraes
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionPaul Irish
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxwhitneyleman54422
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the newRemy Sharp
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformanceAndrás Kovács
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreNicolas Carlo
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First WidgetChris Wilcoxson
 

Ähnlich wie React.js: Beyond the Browser (20)

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
 
React 101
React 101React 101
React 101
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
 
Practical Event Sourcing
Practical Event SourcingPractical Event Sourcing
Practical Event Sourcing
 
Intro to jquery
Intro to jqueryIntro to jquery
Intro to jquery
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for Performance
 
ReactJS
ReactJSReactJS
ReactJS
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First Widget
 

Kürzlich hochgeladen

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

React.js: Beyond the Browser

  • 1. REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYOND THE BROWSER REACT.JS: BEYON THE BROWSER REACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYONREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYOREACT.JS: BEYO REACT.JS: BEYOND THE BROWSER @gabescholz
  • 2.
  • 3. “just remember I am going after you” - Godfrey Chan, wannabe Thought Leader
  • 4. “the whole reason I am doing the talk is to go after you”
  • 5.
  • 7. “… the latest and greatest JavaScript framework comes around every sixteen minutes.” - Allen Pike, King of VanJS http://www.allenpike.com/2015/javascript-framework-fatigue/
  • 8. “Helping you select an MV* framework” ! (with 64 different choices!!) http://todomvc.com/
  • 9. CHOICE PARALYSIS /noun/ ! ! the state of being unable to select a proper JavaScript framework ! “I literally can’t feel my legs due to this choice paralysis.” http://www.sitepoint.com/drowning-in-tools-web-development-industry/
  • 10. “… people come from a wide variety of backgrounds, and have a wide variety of goals. This constant inflow of new ideas and interests has made the JavaScript community unusually diverse.” http://www.allenpike.com/2015/javascript-framework-fatigue/
  • 11. FOAM“FOAM is a full-stack, reactive, deeply MVC metaprogramming Javascript framework.” <meta name=“description” … />
  • 12.
  • 13.
  • 14.
  • 16. e
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. 2. “Learn once, Write anywhere” 1. Why React?
  • 22. 😍 Everything is JavaScript
  • 23. <!-- template.html --> ! <weather-widget forecast=“forecast”> <weather-link href=“http://weather.ca”> sherr, bud </weather-link> </weather-widget>
  • 24. // component.js ! <WeatherWidget forecast={forecast}> <WeatherLink href=“http://weather.ca”> sherr, bud </WeatherLink> </WeatherWidget>
  • 25. // component.js ! React.createElement(WeatherWidget, { forecast: forecast }, React.createElement(WeatherLink, { href: “http://weather.ca” }, “sherr, bud” ) ) Dat JSX, tho
  • 26. // component.js ! React.createElement(“div”, {}, React.createElement(“a”, { href: “http://weather.ca” }, “sherr, bud” ) ) Dat JSX, tho FEELS GOOD MAN
  • 27. var WeatherApp = React.createClass({ getInitialState () { return { forecast: ‘sunny’ }; }, 
 render () { var forecast = this.state.forecast; ! return ( <WeatherWidget forecast={forecast}> <WeatherLink href=“http://weather.ca”> sherr, bud </WeatherLink> </WeatherWidget> ) } });
  • 29.
  • 30. renderA: <div /> renderB: <span /> [removeNode <div />], [insertNode <span />]
  • 31. renderA: <PuttyPatrol /> renderB: <Goldar /> [removeNode <PuttyPatrol />], [insertNode <Goldar />]
  • 32. renderA: <div id="ahHhhhHh" /> renderB: <div id=“after-10000-years-im-free” /> [replaceAttribute id "after-10000-years-im-free"]
  • 34. STATE vs PROPS in TWO MINUTES
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. var Parent = React.createClass({ // ... render () { return ( <div> <Son name={this.state.sonsName} /> <Daughter name={this.state.daughtersName} /> </div> ); } }); ! var Daughter = React.createClass({ // ... render () { return ( <div> <div>{this.props.name}</div> <div>{this.state.favouriteColor}</div> <Dog name=`Mini ${this.props.name}` /> </div> ); } });
  • 43. var Parent = React.createClass({ // … ! updateToLaquesha () { this.setState({ daughtersName: “Laquesha” }); }, ! render () { return ( <div> <button onClick={this.updateToLaquesha} /> <Son name={this.state.sonsName} /> <Daughter name={this.state.daughtersName} /> </div> ); } });
  • 45. React Canvas Created by Flipboard 60 fps on mobile browsers Last commit ~1 week after React Native released publicly
  • 46. <Surface> <Layer> <Text style={{ fontFace: ‘Calibri’, fontSize: ‘40pt’ }}>{this.state.text}</Text> </Layer> </Surface> ` var context = canvas.getContext(‘2d’); context.font = '40pt Calibri'; context.fillText(text, 0, 0);
  • 47. React Native Created by Facebook All of your business logic is written and runs in JavaScript using JavaScriptCore on iOS UI Kit instead of DOM Nodes
  • 48. <div> <img src=“http://i.imgur.com/OBB7tLg.gif” /> <input type=“text” /> <span>sherrr, bud</span> </div> <View> <Image source={{uri: “http://i.imgur.com/ OBB7tLg.gif”}} /> <TextInput /> <Text>sherrr, bud</Text> </View> React Native *style required but not included
  • 49. ReactGibbon Created by Netflix Runs on their Gibbon platform Renders JSON instead of DOM
  • 50. ` I SHOULD PUT REACT ON SOMETHINGI SHOULD PUT REACT ON SOMETHING
  • 52. var card = UI.Card({ title: “Fetching movies list”, subtitle: “Just a minute..”, body: “1 sec..” }); card.show(); // ... card.hide(); ! ! ! ! ! ! ! <Card title=“Fetching movies list” subtitle=“Just a minute..” body=“1 sec..” />
  • 53. var list = UI.List(); list.sections([{}]); // for every item var items = list.items(0); list.items(0, items.concat(item)); ! list.show(); // ... list.hide(); ! ! ! ! ! <List onSelect={this.handleSelect}> <Item title=“..” ... />
 <Item title=“..” ... /> <Item title=“..” ... /> <Item title=“..” ... /> </List>
  • 54. var App = React.createClass({ getInitialState () { }, selectItem (item) { }, ! componentDidMount () { ajax(apiUrl, (response) => { this.setState({ movies: response[1].movies }) }); }, ! render () { var movies = this.state.movies.map( movie => { return (<Item title={movie.title} data={movie} />); }); ! if (movies.length) { return <List onSelect={this.selectItem}>{movies}</List>; } else { return <Card ... />; } } });
  • 55. var App = React.createClass({ getInitialState () { return { movies: [] } }, selectItem (item) { }, ! componentDidMount () { ajax(apiUrl, (response) => { this.setState({ movies: response[1].movies }) }); }, ! render () { var movies = this.state.movies.map( movie => { return (<Item title={movie.title} data={movie} />); }); ! if (movies.length) { return <List onSelect={this.selectItem}>{movies}</List>; } else { return <Card ... />; } } });
  • 56. var App = React.createClass({ getInitialState () { }, selectItem (item) { }, ! componentDidMount () { ajax(apiUrl, (response) => { this.setState({ movies: response[1].movies }) }); }, ! render () { var movies = this.state.movies.map( movie => { return (<Item title={movie.title} data={movie} />); }); ! if (movies.length) { return <List onSelect={this.selectItem}>{movies}</List>; } else { return <Card ... />; } } });
  • 57. var App = React.createClass({ getInitialState () { }, selectItem (item) { }, ! componentDidMount () { ajax(apiUrl, (response) => { this.setState({ movies: response[1].movies }) }); }, ! render () { var movies = this.state.movies.map( movie => { return (<Item title={movie.title} data={movie} />); }); ! if (movies.length) { return <List onSelect={this.selectItem}>{movies}</List>; } else { return <Card ... />; } } });
  • 58. 😛 Becoming a React trickster
  • 59. function createComponent(name) { ! var CustomComponent = function(props) { this.node = new PebbleNode(); this.subscriptions = null; this.listeners = null; this._mountImage = null; this._renderedChildren = null; }; ! CustomComponent.displayName = name; ! for (var i = 1, l = arguments.length; i < l; i++) { assign(CustomComponent.prototype, arguments[i]); } ! return CustomComponent; }
  • 60. function createComponent(name) { ! var CustomComponent = function(props) { this.node = new PebbleNode(); this.subscriptions = null; this.listeners = null; this._mountImage = null; this._renderedChildren = null; }; ! CustomComponent.displayName = name; ! for (var i = 1, l = arguments.length; i < l; i++) { assign(CustomComponent.prototype, arguments[i]); } ! return CustomComponent; }
  • 61. function createComponent(name) { ! var CustomComponent = function(props) { this.node = new PebbleNode(); this.subscriptions = null; this.listeners = null; this._mountImage = null; this._renderedChildren = null; }; ! CustomComponent.displayName = name; ! for (var i = 1, l = arguments.length; i < l; i++) { assign(CustomComponent.prototype, arguments[i]); } ! return CustomComponent; }
  • 62. var Card = createComponent( ‘Card’, NodeMixin, ComponentMixin, ..., { /* additional behaviours */ } ); ! var PebbleApp = React.createClass({ render () { return ( <Card title=“Hello World!”/> ); } }); ! renderPebble(<PebbleApp />);
  • 63. var NodeMixin = { putEventListener (...) { /* ... */ }, handleEvent (...) { /* ... */ }, destroyEventListeners (...) { /* ... */ }, applyNodeProps (...) { /* ... */ } }; ! var ContainerMixin = assign({}, ReactMultiChild.Mixin, { moveChild (...) { /* ... */ }, createChild (...) { /* ... */ }, replaceChild (...) { /* ... */ }, updateChildrenAtRoot (...) { /* ... */ }, mountAndInjectChildren (...) { /* ... */ } }); ! // per component { construct (...) { /* ... */ }, mountComponent (...) { /* ... */ }, unmountComponent (...) { /* ... */ }, receiveComponent (...) { /* ... */ } };
  • 64. var Card = createComponent(‘Card’, NodeMixin, { construct (element) { this._currentElement = element; this.__instance = new UI.Card(); }, mountComponent (rootID, transaction, context) { var props = this._currentElement.props; this._rootNodeID = rootID; ! this.__instance.prop(props); this.__instance.show(); ! return this.node; }, unmountComponent () { this.__instance.hide(); }, receiveComponent (element) { this._currentElement = element; this.__instance.prop(element.props); } });
  • 65. var Card = createComponent(‘Card’, NodeMixin, { construct (element) { this._currentElement = element; this.__instance = new UI.Card(); }, mountComponent (rootID, transaction, context) { var props = this._currentElement.props; this._rootNodeID = rootID; ! this.__instance.prop(props); this.__instance.show(); ! return this.node; }, unmountComponent () { this.__instance.hide(); }, receiveComponent (element) { this._currentElement = element; this.__instance.prop(element.props); } });
  • 66. var Card = createComponent(‘Card’, NodeMixin, { construct (element) { this._currentElement = element; this.__instance = new UI.Card(); }, mountComponent (rootID, transaction, context) { var props = this._currentElement.props; this._rootNodeID = rootID; ! this.__instance.prop(props); this.__instance.show(); ! return this.node; }, unmountComponent () { this.__instance.hide(); }, receiveComponent (element) { this._currentElement = element; this.__instance.prop(element.props); } });
  • 67. var Card = createComponent(‘Card’, NodeMixin, { construct (element) { this._currentElement = element; this.__instance = new UI.Card(); }, mountComponent (rootID, transaction, context) { var props = this._currentElement.props; this._rootNodeID = rootID; ! this.__instance.prop(props); this.__instance.show(); ! return this.node; }, unmountComponent () { this.__instance.hide(); }, receiveComponent (element) { this._currentElement = element; this.__instance.prop(element.props); } });
  • 68. var Card = createComponent(‘Card’, NodeMixin, { construct (element) { this._currentElement = element; this.__instance = new UI.Card(); }, mountComponent (rootID, transaction, context) { var props = this._currentElement.props; this._rootNodeID = rootID; ! this.__instance.prop(props); this.__instance.show(); ! return this.node; }, unmountComponent () { this.__instance.hide(); }, receiveComponent (element) { this._currentElement = element; this.__instance.prop(element.props); } });