SlideShare a Scribd company logo
REACTA PRESENTATION FOR OTTAWAJS
Hello
@brucelefebvre
REACT:
A JAVASCRIPT LIBRARY FOR CREATING
USER INTERFACES
Why React?
Component based
Fast
Performance
To learn
Simple
No templates
Means no abstractions
Markup lives with its corresponding view logic
Demo!
On the Shoulders of Giants
React - http://facebook.github.io/react/
React Router - https://rackt.github.io/react-router/
React Intl - http://formatjs.io/react/
Ionic Framework CSS - http://ionicframework.com/
Firebase - https://www.firebase.com/
PhoneGap - http://phonegap.com/
Dashboard Components
Dashboard Components
Dashboard
Header
EventSelector
EventTypeLink
EventHistory
Event
DiaperEvent
FormattedRelative
OttawaJS - React
AddDiaperEvent
Header
DiaperEventForm
TimeSelector
...with React, the only
thing you do is build
components.
- Why React?
Your First Component
var Header = React.createClass({
render: function() {
return (
<h1>{this.props.title}</h1>
);
}
});
Use It
var Header = React.createClass({
render: function() {
return (
<h1>{this.props.title}</h1>
);
}
});
React.render(
<Header title="Poop Monitor" />,
document.getElementById('app')
);
Component Basics
Component output is simply a function of
`state` and `props`
Data flows from "Owner to Owned"
<Parent><Child /></Parent>
Declarative
Focus is on _what_ the program should
accomplish without prescribing how to do it
A Stateful Component
var EventHistory = React.createClass({
getInitialState: function() {
return {events: []};
},
componentWillMount: function() {
var eventItems = [];
this.dataProvider = new PMDataProvider();
this.dataProvider.getEvents(function(event) {
// `unshift` used instead of `push` to place the newest items at the top
eventItems.unshift(event);
this.setState({
events: eventItems
});
}.bind(this));
},
componentWillUnmount: function() {
this.dataProvider.close();
},
render: function() {
var eventNodes = this.state.events.map(function (event, keyIndex) {
var eventComponent;
if (event.type === "Diaper") {
return (<DiaperEvent event={event} key={keyIndex} />);
}
else {
return (<Event event={event} key={keyIndex} />);
}
});
return (
<div className="list card">
{eventNodes}
</div>
);
}
});
Let's Break it Down
var EventHistory = React.createClass({
getInitialState: function() {
// Set up the component's initial state
},
componentWillMount: function() {
// Component is about to be rendered
},
componentWillUnmount: function() {
// Component is about to be removed from the DOM
},
render: function() {
// Returns a single child element
// Pure:
// - Does not modify state
// - Does not interact with the DOM directly
// - Returns same result each time it is invoked
}
});
More on component lifecycle methods can be found here
...code is read far more
than it's written, and it's
extremely easy to read
this modular, explicit
code.
- Pete Hunt, Thinking in React
Speed: at a price
No two-way data binding; `props` flow from parent to child
Form element data often needs to propogate up
var GenericEventForm = React.createClass({
onDateUpdate: function(date) {
// Deal with the updated date
},
render: function() {
return (
<form className="eventForm">
<TimeSelector onUpdate={this.onDateUpdate}/>
</form>
)
}
});
var TimeSelector = React.createClass({
timeSelectionChanged: function(e) {
var eventDate = new Date(); // manipulate date as required
this.props.onUpdate(eventDate);
},
render: function() {
// Simplified for code sample
return (
<input type="radio" name="timeOption" onChange={this.timeSelectionChanged} />
);
}
});
Gotchas
Use an NPM/Gulp/Browserify workflow from the start
Like this react-app-boilerplate
Beware copying source from non-React samples
`class` becomes `className`
`for` becomes `htmlFor`
React is not a monolithic framework like Angular
It will not make XHRs for you
It does not handle routing between views
You will have to code your own page transitions
Thanks!
Project source on Github: bit.ly/ott-react
Ad

More Related Content

What's hot (20)

Lecture5
Lecture5Lecture5
Lecture5
Châu Thanh Chương
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
Commit University
 
Building a Single Page App: One Page at a Time
Building a Single Page App: One Page at a TimeBuilding a Single Page App: One Page at a Time
Building a Single Page App: One Page at a Time
Ivayr Farah Netto
 
Railsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and webRailsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and web
talkingquickly
 
React on es6+
React on es6+React on es6+
React on es6+
Nikolaus Graf
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
Intro to Flux - ReactJS Warsaw #1
Intro to Flux - ReactJS Warsaw #1Intro to Flux - ReactJS Warsaw #1
Intro to Flux - ReactJS Warsaw #1
Damian Legawiec
 
Building high-performance web applications with Preact
Building high-performance web applications with PreactBuilding high-performance web applications with Preact
Building high-performance web applications with Preact
Maurice De Beijer [MVP]
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
Jo Cranford
 
7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
reactima
 
React and redux
React and reduxReact and redux
React and redux
Mystic Coders, LLC
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Tu Hoang
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...
Katy Slemon
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
Mitch Chen
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular
Jalpesh Vadgama
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
PostgREST Design Philosophy
PostgREST Design PhilosophyPostgREST Design Philosophy
PostgREST Design Philosophy
begriffs
 
Flux and React.js
Flux and React.jsFlux and React.js
Flux and React.js
sara stanford
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Building a Single Page App: One Page at a Time
Building a Single Page App: One Page at a TimeBuilding a Single Page App: One Page at a Time
Building a Single Page App: One Page at a Time
Ivayr Farah Netto
 
Railsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and webRailsconf 2017 - React & React Native a common codebase across native and web
Railsconf 2017 - React & React Native a common codebase across native and web
talkingquickly
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
Intro to Flux - ReactJS Warsaw #1
Intro to Flux - ReactJS Warsaw #1Intro to Flux - ReactJS Warsaw #1
Intro to Flux - ReactJS Warsaw #1
Damian Legawiec
 
Building high-performance web applications with Preact
Building high-performance web applications with PreactBuilding high-performance web applications with Preact
Building high-performance web applications with Preact
Maurice De Beijer [MVP]
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
Jo Cranford
 
7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
reactima
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Tu Hoang
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...
Katy Slemon
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
Mitch Chen
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular
Jalpesh Vadgama
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
PostgREST Design Philosophy
PostgREST Design PhilosophyPostgREST Design Philosophy
PostgREST Design Philosophy
begriffs
 

Similar to OttawaJS - React (20)

ReactJS
ReactJSReactJS
ReactJS
Ram Murat Sharma
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Intro react js
Intro react jsIntro react js
Intro react js
Vijayakanth MP
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJS
LinkMe Srl
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
Ryan Anklam
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
Jean Carlo Emer
 
A React Journey
A React JourneyA React Journey
A React Journey
LinkMe Srl
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
Yao Nien Chung
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with React
Netcetera
 
The Exciting Future Of React
The Exciting Future Of ReactThe Exciting Future Of React
The Exciting Future Of React
kristijanmkd
 
React js
React jsReact js
React js
Rajesh Kolla
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
RAJNISH KATHAROTIYA
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
George Tony
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
kiranabburi
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
DayNightGaMiNg
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)
tuanpa206
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJS
LinkMe Srl
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
Ryan Anklam
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
Jean Carlo Emer
 
A React Journey
A React JourneyA React Journey
A React Journey
LinkMe Srl
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
Yao Nien Chung
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with React
Netcetera
 
The Exciting Future Of React
The Exciting Future Of ReactThe Exciting Future Of React
The Exciting Future Of React
kristijanmkd
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
kiranabburi
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)
tuanpa206
 
Ad

Recently uploaded (20)

Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Ad

OttawaJS - React

  • 3. REACT: A JAVASCRIPT LIBRARY FOR CREATING USER INTERFACES
  • 4. Why React? Component based Fast Performance To learn Simple No templates Means no abstractions Markup lives with its corresponding view logic
  • 6. On the Shoulders of Giants React - http://facebook.github.io/react/ React Router - https://rackt.github.io/react-router/ React Intl - http://formatjs.io/react/ Ionic Framework CSS - http://ionicframework.com/ Firebase - https://www.firebase.com/ PhoneGap - http://phonegap.com/
  • 11. ...with React, the only thing you do is build components. - Why React?
  • 12. Your First Component var Header = React.createClass({ render: function() { return ( <h1>{this.props.title}</h1> ); } });
  • 13. Use It var Header = React.createClass({ render: function() { return ( <h1>{this.props.title}</h1> ); } }); React.render( <Header title="Poop Monitor" />, document.getElementById('app') );
  • 14. Component Basics Component output is simply a function of `state` and `props` Data flows from "Owner to Owned" <Parent><Child /></Parent> Declarative Focus is on _what_ the program should accomplish without prescribing how to do it
  • 15. A Stateful Component var EventHistory = React.createClass({ getInitialState: function() { return {events: []}; }, componentWillMount: function() { var eventItems = []; this.dataProvider = new PMDataProvider(); this.dataProvider.getEvents(function(event) { // `unshift` used instead of `push` to place the newest items at the top eventItems.unshift(event); this.setState({ events: eventItems }); }.bind(this)); }, componentWillUnmount: function() { this.dataProvider.close(); }, render: function() { var eventNodes = this.state.events.map(function (event, keyIndex) { var eventComponent; if (event.type === "Diaper") { return (<DiaperEvent event={event} key={keyIndex} />); } else { return (<Event event={event} key={keyIndex} />); } }); return ( <div className="list card"> {eventNodes} </div> ); } });
  • 16. Let's Break it Down var EventHistory = React.createClass({ getInitialState: function() { // Set up the component's initial state }, componentWillMount: function() { // Component is about to be rendered }, componentWillUnmount: function() { // Component is about to be removed from the DOM }, render: function() { // Returns a single child element // Pure: // - Does not modify state // - Does not interact with the DOM directly // - Returns same result each time it is invoked } }); More on component lifecycle methods can be found here
  • 17. ...code is read far more than it's written, and it's extremely easy to read this modular, explicit code. - Pete Hunt, Thinking in React
  • 18. Speed: at a price No two-way data binding; `props` flow from parent to child Form element data often needs to propogate up var GenericEventForm = React.createClass({ onDateUpdate: function(date) { // Deal with the updated date }, render: function() { return ( <form className="eventForm"> <TimeSelector onUpdate={this.onDateUpdate}/> </form> ) } }); var TimeSelector = React.createClass({ timeSelectionChanged: function(e) { var eventDate = new Date(); // manipulate date as required this.props.onUpdate(eventDate); }, render: function() { // Simplified for code sample return ( <input type="radio" name="timeOption" onChange={this.timeSelectionChanged} /> ); } });
  • 19. Gotchas Use an NPM/Gulp/Browserify workflow from the start Like this react-app-boilerplate Beware copying source from non-React samples `class` becomes `className` `for` becomes `htmlFor` React is not a monolithic framework like Angular It will not make XHRs for you It does not handle routing between views You will have to code your own page transitions
  • 21. Project source on Github: bit.ly/ott-react