SlideShare a Scribd company logo
A J O U R N E Y W I T H R E A C T
TA S V E E R S I N G H
@ t a z s i n g h
A Journey with React
A Journey with React
A Journey with React
3 A P P S
– M I K E H O U R A H I N E
“You can learn trigonometry, physics, C++, and DirectX to make a video game.
Or you can make a video game and learn DirectX, C++, physics, and
trigonometry.”
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
A P P # 1 - R E A C T A S A T E M P L AT I N G E N G I N E
• Server side application framework
• Nashorn JavaScript engine for Java 8
• Vert.x 2.3 - Polyglot Event-Driven Messaging
• Innovative Router
• React to describe HTML
A P P # 2 - F L U X
A Journey with React
A Journey with React
A Journey with React
M
C
C
C
C
V
V
V
V
M
M
C
C
C
C
V
V
V
V
M
A Journey with React
A P P # 2 - F L U X
• My first iteration relied on my experience from MVC
• Business logic resides in Models/Stores
• Fat models, skinny controllers
• Models/Stores make AJAX calls
• Actions were very light weight notifications to the Stores
function signInUser(username, password) {
Dispatcher.dispatch({
type: ActionTypes.USER_SIGN_IN
, username: username
, password: password
});
}
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((action) => {
switch(action.type) {
case ActionTypes.USER_SIGN_IN:
fetchUser(action.username, action.password).then(
(response) => {
this.currentUser = response.user;
this.emit(“change”);
});
}
});
}
function getState() {
return { currentUser: UserStore.currentUser }
}
class SignInComponent extends React.Component {
state = getState();
handleStateChange() { this.setState(getState()); }
componentDidMount() { UserStore.on(“change”, this.handleStateChange); }
componentWillUnmount() {
UserStore.removeListener(“change”, this.handleStateChange);
}
handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your
password?”)); }
render() {
if(!this.state.currentUser)
return <a onClick={this.handleAuth}>Click here to sign in</a>;
else
return <p>You’re signed in as {this.state.currentUser.name}</p>;
}
}
A P P # 2 - F L U X - F I R S T I T E R AT I O N
• Facebook’s Dispatcher does not allow you to dispatch from a dispatch
• Difficult to compose application flow
• How do you handle errors?
• Relies on the Global State of ActionTypes
• Views worked great!
N E X T I T E R AT I O N
T RY C O M P O S I N G A C T I O N S
class SignInUser extends BaseAction {
constructor(username, password, alreadySignedInUser) {
this.username = username;
this.password = password;
this.alreadySignedInUser = alreadySignedInUser;
if(!this.alreadySignedInUser) this.authUser();
}
authUser() {
fetchUser(this.username, this.password).then(
(newUser) => { new SignInSuccess(newUser); }
, (errors) => { new SignInFailure(errors); }
);
}
A Journey with React
class SignInUser extends BaseAction {
constructor(username, password, alreadySignedInUser) {
this.username = username;
this.password = password;
this.alreadySignedInUser = alreadySignedInUser;
if(!this.alreadySignedInUser) this.authUser();
}
authUser() {
fetchUser(this.username, this.password).then(
(newUser) => { new SignInSuccess(newUser); }
, (errors) => { new SignInFailure(errors); }
);
}
class SignInSuccess
extends BaseAction {
constructor(newUser) {
this.newUser =
newUser;
this.dispatch();
}
}
class SignInFailure
extends BaseAction {
constructor(errors) {
this.errors = errors;
this.dispatch();
new
FlashMessage(“Could not
sign in”);
}
}
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((action) => {
switch(action.constructor) {
case SignInSuccess:
this.currentUser = action.newUser;
this.emit(“change”);
}
});
}
A P P # 2 - F L U X - 2 N D I T E R AT I O N
• Eliminates the “dispatching from a dispatch” problem
• Stores are synchronous
• Very easy to compose the flow of your application by composing actions
• Eliminated Global State of ActionTypes
• Extremely scalable solution
• Easy to test
• In a later iteration, dropped in WebPack
A P P # 3 - B R O C H U R E W E B S I T E
A P P # 3 - B R O C H U R E W E B S I T E
• SEO is paramount
• AJAX is bad for SEO
• Performant on Desktop and Mobile
• Server Side Rendered
• Incremental Loading
• Introduce server side developers to client side technologies
• ES6/ES2015 via Babel
• React + Flux + WebPack
A P P # 3 - B R O C H U R E W E B S I T E
• Server side React + Server side Flux
• WebPack manages front end assets, inlining, and chunking
• Incremental loading by chunking
• Reduce number of web requests by inlining
• Koa.js serves the application and handles routing
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
A Journey with React
G R I F F I N . J S
G R I F F I N . J S
• Includes everything I’ve learnt and more
• Facebook’s Dispatcher
• React Views
• Griffin Actions - Same as previous examples
• Redux Stores w/ Griffin Connector to Views
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((payload) => {
switch(payload.constructor) {
case SignInSuccess:
this.currentUser = payload.newUser;
this.emit(“change”);
}
});
}
class UserStore extends GriffinStore {
reducer(state = null, action) => {
switch(action.constructor) {
case SignInSuccess:
return payload.newUser;
default:
return state;
}
});
}
function getState() {
return { currentUser: UserStore.currentUser }
}
class SignInComponent extends React.Component {
state = getState();
handleStateChange() { this.setState(getState()); }
componentDidMount() { UserStore.on(“change”, this.handleStateChange); }
componentWillUnmount() {
UserStore.removeListener(“change”, this.handleStateChange);
}
handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your
password?”)); }
render() {
if(!this.state.currentUser)
return <a onClick={this.handleAuth}>Click here to sign in</a>;
else
return <p>You’re signed in as {this.state.currentUser.name}</p>;
}
}
@connect({ currentUser: UserStore })
class SignInComponent extends React.Component {
handleAuth(event) { signInUser(prompt(“What’s your
username?”), prompt(“What’s your password?”)); }
render() {
if(!this.props.currentUser)
return <a onClick={this.handleAuth}>Click here to
sign in</a>;
else
return <p>You’re signed in as
{this.props.currentUser.name}</p>;
}
}
R E A C T D E P E N D E N C Y I N J E C T I O N
• Using props to pass in external data is similar to Angular’s dependency
injection
• Only use state to manage internal component state
• <SignInComponent currentUser={{name: “Mock User!”}} />
• <SignInComponent currentUser={null} />
R E A C T R O U T E R
R E A C T R O U T E R
• Amazing routing solution - Inspired heavily by Ember’s router
• Ember has an excellent router
• Uses JSX or JSON to describe routes and nested routes
• React Component will be loaded by a Route
• Version 1.0 has lazy loading of routes and components
• Better Server Side Rendering
React.render((
<Router>
<Route path="/" component={App}>
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
<Route path="messages/:id"
component={Message} />
</Route>
</Route>
</Router>
), document.body)
.
├── AppComponent.js => /
├── AboutComponent.js => /about
├── InboxComponent.js => /inbox
└── MessageComponent.js => /inbox/messages/:id
.
├── AppComponent.js => /
├── AboutComponent.js => /about
├── InboxComponent.js => /inbox
└── inbox
   └── MessageComponent.js => /inbox/messages/:id
.
├── index.js => /
├── about
│   └── index.js => /about
└── inbox
   ├── index.js => /inbox
   └── messages
   └── @id
   └── index.js => /inbox/messages/:id
.
├── index.js => /
├── about
│   └── index.js => /about
└── inbox
   ├── DeleteMessage.js
   ├── GetMessages.js
   ├── MessageStore.js
   ├── index.js => /inbox
   └── messages
   └── @id
   └── index.js => /inbox/messages/:id
React.render((
<Router>
<Route path="/" component={App}>
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
<Route path="messages/:id"
component={Message} />
</Route>
</Route>
</Router>
), document.body)
G R I F F I N F I L E S Y S T E M B A S E D R O U T I N G
• Easy to initialize your app
• import myApp from “griffin!.”;

myApp({ /* any griffin options here */});
• Easy to mount other apps
• import anotherApp from “griffin!/path/to/app”;

anotherApp({ /* griffin options */});
U N I V E R S A L A P P S W I T H W E B PA C K
• Everything goes through WebPack
• Based on James Long’s excellent “Backend Apps with WebPack” posts
• On the server, it ignores CSS, images, etc.
• WebPack enables lazy-loading of application chunks
• Incrementally load Griffin routes
• Include common modules with initial payload
G R I F F I N . J S S TAT U S
• Almost ready for release
• Planning to release in the next few months
• I’m currently rewriting the WebPack incremental file-system based routing
• Last core item remaining before release
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
T H A N K Y O U
@ t a z s i n g h
Ad

More Related Content

What's hot (20)

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
 
ReactJS
ReactJSReactJS
ReactJS
Kamlesh Singh
 
Kakunin E2E framework showcase
Kakunin E2E framework showcaseKakunin E2E framework showcase
Kakunin E2E framework showcase
The Software House
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
Boris Dinkevich
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
Boris Dinkevich
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
giurca
 
React with Redux
React with ReduxReact with Redux
React with Redux
Stanimir Todorov
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
Simon Willison
 
Extending Redux in the Server Side
Extending Redux in the Server SideExtending Redux in the Server Side
Extending Redux in the Server Side
Ignacio Martín
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
rajkamaltibacademy
 
amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5
mennovanslooten
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
dmethvin
 
Take My Logs. Please!
Take My Logs. Please!Take My Logs. Please!
Take My Logs. Please!
Mike Brittain
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
Frank de Jonge
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
howlowck
 
JavaScript Testing for Rubyists
JavaScript Testing for RubyistsJavaScript Testing for Rubyists
JavaScript Testing for Rubyists
Jamie Dyer
 
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
 
High Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScript
Leonardo Borges
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
Joseph Chiang
 
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
 
Kakunin E2E framework showcase
Kakunin E2E framework showcaseKakunin E2E framework showcase
Kakunin E2E framework showcase
The Software House
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
Boris Dinkevich
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
giurca
 
Extending Redux in the Server Side
Extending Redux in the Server SideExtending Redux in the Server Side
Extending Redux in the Server Side
Ignacio Martín
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
rajkamaltibacademy
 
amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5
mennovanslooten
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
dmethvin
 
Take My Logs. Please!
Take My Logs. Please!Take My Logs. Please!
Take My Logs. Please!
Mike Brittain
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
howlowck
 
JavaScript Testing for Rubyists
JavaScript Testing for RubyistsJavaScript Testing for Rubyists
JavaScript Testing for Rubyists
Jamie Dyer
 
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
 
High Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScript
Leonardo Borges
 

Viewers also liked (20)

The Working Dead
The Working DeadThe Working Dead
The Working Dead
FITC
 
Creating a Smile Worthy World
Creating a Smile Worthy WorldCreating a Smile Worthy World
Creating a Smile Worthy World
FITC
 
Your UX is not my UX
Your UX is not my UXYour UX is not my UX
Your UX is not my UX
FITC
 
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric BoydGamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
FITC
 
Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
FITC
 
A New Era for Animators
A New Era for AnimatorsA New Era for Animators
A New Era for Animators
FITC
 
Design to the Future
Design to the FutureDesign to the Future
Design to the Future
FITC
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
FITC
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
FITC
 
Getting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own PluginGetting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own Plugin
FITC
 
(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think
FITC
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Open Sourcing the Secret Sauce
Open Sourcing the Secret SauceOpen Sourcing the Secret Sauce
Open Sourcing the Secret Sauce
FITC
 
Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
FITC
 
Embedding Cognitive Innovation in Design
Embedding Cognitive Innovation in DesignEmbedding Cognitive Innovation in Design
Embedding Cognitive Innovation in Design
FITC
 
Graphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing EvolutionGraphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing Evolution
FITC
 
The Future is in Pieces
The Future is in PiecesThe Future is in Pieces
The Future is in Pieces
FITC
 
Front-end Tools: Sifting Through the Madness
 Front-end Tools: Sifting Through the Madness Front-end Tools: Sifting Through the Madness
Front-end Tools: Sifting Through the Madness
FITC
 
The Giddiest Kipper
The Giddiest KipperThe Giddiest Kipper
The Giddiest Kipper
FITC
 
The Working Dead
The Working DeadThe Working Dead
The Working Dead
FITC
 
Creating a Smile Worthy World
Creating a Smile Worthy WorldCreating a Smile Worthy World
Creating a Smile Worthy World
FITC
 
Your UX is not my UX
Your UX is not my UXYour UX is not my UX
Your UX is not my UX
FITC
 
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric BoydGamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
FITC
 
Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
FITC
 
A New Era for Animators
A New Era for AnimatorsA New Era for Animators
A New Era for Animators
FITC
 
Design to the Future
Design to the FutureDesign to the Future
Design to the Future
FITC
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
FITC
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
FITC
 
Getting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own PluginGetting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own Plugin
FITC
 
(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think
FITC
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Open Sourcing the Secret Sauce
Open Sourcing the Secret SauceOpen Sourcing the Secret Sauce
Open Sourcing the Secret Sauce
FITC
 
Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
FITC
 
Embedding Cognitive Innovation in Design
Embedding Cognitive Innovation in DesignEmbedding Cognitive Innovation in Design
Embedding Cognitive Innovation in Design
FITC
 
Graphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing EvolutionGraphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing Evolution
FITC
 
The Future is in Pieces
The Future is in PiecesThe Future is in Pieces
The Future is in Pieces
FITC
 
Front-end Tools: Sifting Through the Madness
 Front-end Tools: Sifting Through the Madness Front-end Tools: Sifting Through the Madness
Front-end Tools: Sifting Through the Madness
FITC
 
The Giddiest Kipper
The Giddiest KipperThe Giddiest Kipper
The Giddiest Kipper
FITC
 
Ad

Similar to A Journey with React (20)

Chris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web AppsChris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web Apps
Danielle A Vincent
 
Using ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript ProjectUsing ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript Project
Roy Derks
 
Progressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript AppsProgressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript Apps
Codemotion
 
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
 
A Blog About Using State in Next.js: Valuable Insights
A Blog About Using State in Next.js: Valuable InsightsA Blog About Using State in Next.js: Valuable Insights
A Blog About Using State in Next.js: Valuable Insights
Shiv Technolabs Pvt. Ltd.
 
Week 8
Week 8Week 8
Week 8
A VD
 
N Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React Native
Anton Kulyk
 
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
Ben Teese
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
Metrics-Driven Engineering
Metrics-Driven EngineeringMetrics-Driven Engineering
Metrics-Driven Engineering
Mike Brittain
 
Using React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIsUsing React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIs
Mihail Gaberov
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
xilinus
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
Mike Subelsky
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
Eric Steele
 
Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018
Robert Herbst
 
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
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
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
 
Chris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web AppsChris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web Apps
Danielle A Vincent
 
Using ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript ProjectUsing ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript Project
Roy Derks
 
Progressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript AppsProgressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript Apps
Codemotion
 
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
 
A Blog About Using State in Next.js: Valuable Insights
A Blog About Using State in Next.js: Valuable InsightsA Blog About Using State in Next.js: Valuable Insights
A Blog About Using State in Next.js: Valuable Insights
Shiv Technolabs Pvt. Ltd.
 
Week 8
Week 8Week 8
Week 8
A VD
 
N Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React Native
Anton Kulyk
 
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
Ben Teese
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
Metrics-Driven Engineering
Metrics-Driven EngineeringMetrics-Driven Engineering
Metrics-Driven Engineering
Mike Brittain
 
Using React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIsUsing React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIs
Mihail Gaberov
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
xilinus
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
Mike Subelsky
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
Eric Steele
 
Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018
Robert Herbst
 
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
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
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
 
Ad

More from FITC (20)

Cut it up
Cut it upCut it up
Cut it up
FITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
FITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
FITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
FITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
FITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
FITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
FITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
FITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
FITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
FITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
FITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
FITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
FITC
 
Cut it up
Cut it upCut it up
Cut it up
FITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
FITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
FITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
FITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
FITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
FITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
FITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
FITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
FITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
FITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
FITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
FITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
FITC
 

Recently uploaded (16)

cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdfcxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
ssuser060b2e1
 
Organizing_Data_Grade4 how to organize.pptx
Organizing_Data_Grade4 how to organize.pptxOrganizing_Data_Grade4 how to organize.pptx
Organizing_Data_Grade4 how to organize.pptx
AllanGuevarra1
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
Cyber Safety: security measure about navegating on internet.
Cyber Safety: security measure about navegating on internet.Cyber Safety: security measure about navegating on internet.
Cyber Safety: security measure about navegating on internet.
manugodinhogentil
 
Seminar.MAJor presentation for final project viva
Seminar.MAJor presentation for final project vivaSeminar.MAJor presentation for final project viva
Seminar.MAJor presentation for final project viva
daditya2501
 
AI Days 2025_GM1 : Interface in theage of AI
AI Days 2025_GM1 : Interface in theage of AIAI Days 2025_GM1 : Interface in theage of AI
AI Days 2025_GM1 : Interface in theage of AI
Prashant Singh
 
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdfBreaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Nirmalthapa24
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
AndrHenrique77
 
Grade 7 Google_Sites_Lesson creating website.pptx
Grade 7 Google_Sites_Lesson creating website.pptxGrade 7 Google_Sites_Lesson creating website.pptx
Grade 7 Google_Sites_Lesson creating website.pptx
AllanGuevarra1
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdfcxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
cxbcxfzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7.pdf
ssuser060b2e1
 
Organizing_Data_Grade4 how to organize.pptx
Organizing_Data_Grade4 how to organize.pptxOrganizing_Data_Grade4 how to organize.pptx
Organizing_Data_Grade4 how to organize.pptx
AllanGuevarra1
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
Cyber Safety: security measure about navegating on internet.
Cyber Safety: security measure about navegating on internet.Cyber Safety: security measure about navegating on internet.
Cyber Safety: security measure about navegating on internet.
manugodinhogentil
 
Seminar.MAJor presentation for final project viva
Seminar.MAJor presentation for final project vivaSeminar.MAJor presentation for final project viva
Seminar.MAJor presentation for final project viva
daditya2501
 
AI Days 2025_GM1 : Interface in theage of AI
AI Days 2025_GM1 : Interface in theage of AIAI Days 2025_GM1 : Interface in theage of AI
AI Days 2025_GM1 : Interface in theage of AI
Prashant Singh
 
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdfBreaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Breaching The Perimeter - Our Most Impactful Bug Bounty Findings.pdf
Nirmalthapa24
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
5-Ways-To-Future-Proof-Your-SIEM-Securonix[1].pdf
AndrHenrique77
 
Grade 7 Google_Sites_Lesson creating website.pptx
Grade 7 Google_Sites_Lesson creating website.pptxGrade 7 Google_Sites_Lesson creating website.pptx
Grade 7 Google_Sites_Lesson creating website.pptx
AllanGuevarra1
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 

A Journey with React

  • 1. A J O U R N E Y W I T H R E A C T TA S V E E R S I N G H @ t a z s i n g h
  • 5. 3 A P P S
  • 6. – M I K E H O U R A H I N E “You can learn trigonometry, physics, C++, and DirectX to make a video game. Or you can make a video game and learn DirectX, C++, physics, and trigonometry.”
  • 7. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 8. A P P # 1 - R E A C T A S A T E M P L AT I N G E N G I N E • Server side application framework • Nashorn JavaScript engine for Java 8 • Vert.x 2.3 - Polyglot Event-Driven Messaging • Innovative Router • React to describe HTML
  • 9. A P P # 2 - F L U X
  • 16. A P P # 2 - F L U X • My first iteration relied on my experience from MVC • Business logic resides in Models/Stores • Fat models, skinny controllers • Models/Stores make AJAX calls • Actions were very light weight notifications to the Stores
  • 17. function signInUser(username, password) { Dispatcher.dispatch({ type: ActionTypes.USER_SIGN_IN , username: username , password: password }); }
  • 18. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((action) => { switch(action.type) { case ActionTypes.USER_SIGN_IN: fetchUser(action.username, action.password).then( (response) => { this.currentUser = response.user; this.emit(“change”); }); } }); }
  • 19. function getState() { return { currentUser: UserStore.currentUser } } class SignInComponent extends React.Component { state = getState(); handleStateChange() { this.setState(getState()); } componentDidMount() { UserStore.on(“change”, this.handleStateChange); } componentWillUnmount() { UserStore.removeListener(“change”, this.handleStateChange); } handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.state.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.state.currentUser.name}</p>; } }
  • 20. A P P # 2 - F L U X - F I R S T I T E R AT I O N • Facebook’s Dispatcher does not allow you to dispatch from a dispatch • Difficult to compose application flow • How do you handle errors? • Relies on the Global State of ActionTypes • Views worked great!
  • 21. N E X T I T E R AT I O N T RY C O M P O S I N G A C T I O N S
  • 22. class SignInUser extends BaseAction { constructor(username, password, alreadySignedInUser) { this.username = username; this.password = password; this.alreadySignedInUser = alreadySignedInUser; if(!this.alreadySignedInUser) this.authUser(); } authUser() { fetchUser(this.username, this.password).then( (newUser) => { new SignInSuccess(newUser); } , (errors) => { new SignInFailure(errors); } ); }
  • 24. class SignInUser extends BaseAction { constructor(username, password, alreadySignedInUser) { this.username = username; this.password = password; this.alreadySignedInUser = alreadySignedInUser; if(!this.alreadySignedInUser) this.authUser(); } authUser() { fetchUser(this.username, this.password).then( (newUser) => { new SignInSuccess(newUser); } , (errors) => { new SignInFailure(errors); } ); }
  • 25. class SignInSuccess extends BaseAction { constructor(newUser) { this.newUser = newUser; this.dispatch(); } } class SignInFailure extends BaseAction { constructor(errors) { this.errors = errors; this.dispatch(); new FlashMessage(“Could not sign in”); } }
  • 26. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((action) => { switch(action.constructor) { case SignInSuccess: this.currentUser = action.newUser; this.emit(“change”); } }); }
  • 27. A P P # 2 - F L U X - 2 N D I T E R AT I O N • Eliminates the “dispatching from a dispatch” problem • Stores are synchronous • Very easy to compose the flow of your application by composing actions • Eliminated Global State of ActionTypes • Extremely scalable solution • Easy to test • In a later iteration, dropped in WebPack
  • 28. A P P # 3 - B R O C H U R E W E B S I T E
  • 29. A P P # 3 - B R O C H U R E W E B S I T E • SEO is paramount • AJAX is bad for SEO • Performant on Desktop and Mobile • Server Side Rendered • Incremental Loading • Introduce server side developers to client side technologies • ES6/ES2015 via Babel • React + Flux + WebPack
  • 30. A P P # 3 - B R O C H U R E W E B S I T E • Server side React + Server side Flux • WebPack manages front end assets, inlining, and chunking • Incremental loading by chunking • Reduce number of web requests by inlining • Koa.js serves the application and handles routing
  • 31. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 32. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 33. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 35. G R I F F I N . J S
  • 36. G R I F F I N . J S • Includes everything I’ve learnt and more • Facebook’s Dispatcher • React Views • Griffin Actions - Same as previous examples • Redux Stores w/ Griffin Connector to Views
  • 37. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((payload) => { switch(payload.constructor) { case SignInSuccess: this.currentUser = payload.newUser; this.emit(“change”); } }); }
  • 38. class UserStore extends GriffinStore { reducer(state = null, action) => { switch(action.constructor) { case SignInSuccess: return payload.newUser; default: return state; } }); }
  • 39. function getState() { return { currentUser: UserStore.currentUser } } class SignInComponent extends React.Component { state = getState(); handleStateChange() { this.setState(getState()); } componentDidMount() { UserStore.on(“change”, this.handleStateChange); } componentWillUnmount() { UserStore.removeListener(“change”, this.handleStateChange); } handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.state.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.state.currentUser.name}</p>; } }
  • 40. @connect({ currentUser: UserStore }) class SignInComponent extends React.Component { handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.props.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.props.currentUser.name}</p>; } }
  • 41. R E A C T D E P E N D E N C Y I N J E C T I O N • Using props to pass in external data is similar to Angular’s dependency injection • Only use state to manage internal component state • <SignInComponent currentUser={{name: “Mock User!”}} /> • <SignInComponent currentUser={null} />
  • 42. R E A C T R O U T E R
  • 43. R E A C T R O U T E R • Amazing routing solution - Inspired heavily by Ember’s router • Ember has an excellent router • Uses JSX or JSON to describe routes and nested routes • React Component will be loaded by a Route • Version 1.0 has lazy loading of routes and components • Better Server Side Rendering
  • 44. React.render(( <Router> <Route path="/" component={App}> <Route path="about" component={About} /> <Route path="inbox" component={Inbox}> <Route path="messages/:id" component={Message} /> </Route> </Route> </Router> ), document.body)
  • 45. . ├── AppComponent.js => / ├── AboutComponent.js => /about ├── InboxComponent.js => /inbox └── MessageComponent.js => /inbox/messages/:id
  • 46. . ├── AppComponent.js => / ├── AboutComponent.js => /about ├── InboxComponent.js => /inbox └── inbox    └── MessageComponent.js => /inbox/messages/:id
  • 47. . ├── index.js => / ├── about │   └── index.js => /about └── inbox    ├── index.js => /inbox    └── messages    └── @id    └── index.js => /inbox/messages/:id
  • 48. . ├── index.js => / ├── about │   └── index.js => /about └── inbox    ├── DeleteMessage.js    ├── GetMessages.js    ├── MessageStore.js    ├── index.js => /inbox    └── messages    └── @id    └── index.js => /inbox/messages/:id
  • 49. React.render(( <Router> <Route path="/" component={App}> <Route path="about" component={About} /> <Route path="inbox" component={Inbox}> <Route path="messages/:id" component={Message} /> </Route> </Route> </Router> ), document.body)
  • 50. G R I F F I N F I L E S Y S T E M B A S E D R O U T I N G • Easy to initialize your app • import myApp from “griffin!.”;
 myApp({ /* any griffin options here */}); • Easy to mount other apps • import anotherApp from “griffin!/path/to/app”;
 anotherApp({ /* griffin options */});
  • 51. U N I V E R S A L A P P S W I T H W E B PA C K • Everything goes through WebPack • Based on James Long’s excellent “Backend Apps with WebPack” posts • On the server, it ignores CSS, images, etc. • WebPack enables lazy-loading of application chunks • Incrementally load Griffin routes • Include common modules with initial payload
  • 52. G R I F F I N . J S S TAT U S • Almost ready for release • Planning to release in the next few months • I’m currently rewriting the WebPack incremental file-system based routing • Last core item remaining before release
  • 53. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 54. T H A N K Y O U @ t a z s i n g h