SlideShare a Scribd company logo
1 of 95
Download to read offline
Intro to ReactJS
!
!
!
Jeff Winkler
@winkler1
http://react.rocks
What I'll be showing
• Current approaches
• React
• Demos
• Summarize
Webdev Landscape in 2015
JQuery!
$('article.left section').click(function() {
var was_selected = $(this).hasClass('section-selected');
$('article.left section').removeClass('section-selected');
if (!was_selected) {
$(this).addClass('section-selected');
}
});
!
$('article.right section').click(function() {
$(this).toggleClass('right-selected');
if ($('section.right-selected')) {
$(this).children('input.choose').toggle();
}
});
Backbone
Ember
Angular
!
• MVC
• Angular Markup: ng-model, ng-show, ng-repeat
• Dirty checking, speed limitations
• Large API.
• Scopes are inherited.
Angular Scope
Angular Scope
Common Problems
Shared Mutable State
Core Problem
• Separation of Concerns
app/partials/button.html
app/css/button.css
app/js/directives/button.js
REACT
Thesis: React is
• Cohesive
!
• Easy to reason about
Quick History
• Apr 2012: Instagram purchase.
• June 2013 Open-sourced
Users
AirBNB, BBC, CodeAcademy, Dropbox, Facebook,
Flipboard, Github, Imgur, Instagram, Khan
Academy, Netflix, NYT, PayPal, Reddit, Redfin,
Uber, Wired, Yahoo…
Give it 5 Minutes
Simple Component
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
JSX
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
Templating languages have a cost: they make building user
interfaces harder. Doing something simple like alternating row
colors in a table requires jumping through hoops in many languages.
!
What we should do instead is accept that user interfaces are becoming
more and more complicated and that we need a real programming
language (with all of its expressive power) to build user interfaces at
scale.
!
(With React) instead of an oversimplified templating language, you
get to use JavaScript to build abstractions and reuse code.
— Pete Hunt
JSX
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
JSX -> createElement
var HelloMessage = React.createClass({displayName:
"HelloMessage",!
render: function() {!
return React.createElement("div", null, "Hello ",
this.props.name);!
}!
});!
!
React.render(React.createElement(HelloMessage, {name:
"John"}), mountNode);
f(data)=virtual DOM
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
Using a Component
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
Passing props
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
Questions?
var HelloMessage = React.createClass({!
render: function() {!
return <div>Hello {this.props.name}</div>;!
}!
});!
!
React.render(<HelloMessage name="John" />,
mountNode);
State
Timer: has secondsElapsed
var Timer = React.createClass({!
getInitialState() {!
return {secondsElapsed: 0};!
},!
componentDidMount: function() {!
this.interval = setInterval(this.tick, 1000);!
},!
tick() {!
this.setState({secondsElapsed: this.state.secondsElapsed + 1});!
},!
render() {!
return (!
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>!
);!
}!
});
Initialize State
var Timer = React.createClass({!
getInitialState() {!
return {secondsElapsed: 0};!
},!
componentDidMount: function() {!
this.interval = setInterval(this.tick, 1000);!
},!
tick() {!
this.setState({secondsElapsed: this.state.secondsElapsed + 1});!
},!
render() {!
return (!
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>!
);!
}!
});
setState()
var Timer = React.createClass({!
getInitialState() {!
return {secondsElapsed: 0};!
},!
componentDidMount: function() {!
this.interval = setInterval(this.tick, 1000);!
},!
tick() {!
this.setState({secondsElapsed: this.state.secondsElapsed + 1});!
},!
render() {!
return (!
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>!
);!
}!
});
render
var Timer = React.createClass({!
getInitialState() {!
return {secondsElapsed: 0};!
},!
componentDidMount: function() {!
this.interval = setInterval(this.tick, 1000);!
},!
tick() {!
this.setState({secondsElapsed: this.state.secondsElapsed + 1});!
},!
render() {!
return (!
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>!
);!
}!
});
Components -> App
Composition
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
require()
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
Passing data to children
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
Data from parent to child
Need-to-know
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
Questions?
Demos
Virtual DOM!
Creating a component
ReactNative
Demo #1: Virtual DOM
Virtual DOM Demo:
TODOMVC
DOMListener
Our script
• Create new: Apples, Bread
• Check off Apples
• Switch between tabs
Angular
Angular
React
Demos
Virtual DOM
Creating a component!
ReactNative
Demo #2: Encapsulation
• Internal state
• UI actions
• refactoring
Hello World
• import React from 'react';



export default class WhosAsleepScore
extends React.Component {

render() {

return (

<h1>Hello, world!</h1>

);

}

}
Change->Hot Reload
state: {count:0}
code
• import React from 'react';



export default class WhosAsleepScore extends
React.Component {

constructor(props) {

super(props);

this.state={count:0};

}

render() {

let {count}= this.state;

return (

<h1>Who's Asleep score: {count}</h1>

);

}

}
Count the sleepers!
Change Request
!
!
!
!
!
Change display
End Result
import React from 'react';

export default class WhosAsleepScore extends React.Component {

constructor(props) {

super(props);

this.state = {count: 0};

}

addSleeper() {

this.setState({count:this.state.count+1});

}



render() {

return (

<div>

<img src='ct.png' onClick={this.addSleeper.bind(this)} />

<span style={countStyle}>{this.state.count}</span>

</div>

);

}

}
Demos
Virtual DOM
Creating a component!
ReactNative
Demo #3: ReactNative
react-native-spacepics
Demo- Overview
Components
Demo-Changing Code
// if we have an error

if (this.state.error !== null) {

innerNode = <ErrorWidget title="NASA
API Error" message={this.state.error} />;

title = 'Error';

}
If Error
ErrorWidget
• var React = require('react-native');

var {

StyleSheet,

Text,

View,

} = React;



class ErrorWidget extends React.Component {

render() {

return (

<View style={styles.container}>

<Text style={styles.title}>{this.props.title}</Text>

<Text style={styles.message}>{this.props.message}</
Text>

</View>

);

}

}
propTypes
class ErrorWidget extends React.Component {!
propTypes: {!
message: React.PropTypes.string.isRequired,!
title: React.PropTypes.string.isRequired,!
},

render() {

return (

<View style={styles.container}>

<Text style={styles.title}>{this.props.title}</Text>

<Text style={styles.message}>{this.props.message}</Text>

</View>

);

}

}
Loading
// if we don't have a picture

else if (this.state.picture === null) {

innerNode = <Loading title="Getting
Image..." />;

title = 'Loading...';

}!
Loading Widget
• var React = require('react-native');

var {

StyleSheet,

ActivityIndicatorIOS,

Text,

View,

} = React;



class Loading extends React.Component {

render() {

return (

<View style={styles.container}>

<ActivityIndicatorIOS animating={true} />

<Text style={styles.title}>{this.props.title}</Text>

</View>

);

}

}
else: Picture
// if we have a picture

else {

innerNode = <PictureOfTheDay
picture={this.state.picture} />;

title = this.state.picture.title;

}!
Components
Demos
Virtual DOM
Creating a component
ReactNative
Zooming Out
Encapsulation
Composition
SpacePics
PictureOfTheDay
Image
Time
Summary
React is easy to reason about
Where to go from here?
• http://facebook.github.io/react/
• search “Thinking in React”
!
THANK YOU
!
!
Jeff Winkler
@winkler1
http://react.rocks
Reaction to JSX

More Related Content

What's hot

React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overviewAlex Bachuk
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with ReduxVedran Blaženka
 
React for Dummies
React for DummiesReact for Dummies
React for DummiesMitch Chen
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJSAll Things Open
 
Redux training
Redux trainingRedux training
Redux trainingdasersoft
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and ReduxGlib Kechyn
 
Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & ReduxBoris Dinkevich
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and ReconciliationZhihao Li
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.jsDoug Neiner
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React NativeEric Deng
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with ReduxFernando Daciuk
 
Building Modern Web Applications using React and Redux
 Building Modern Web Applications using React and Redux Building Modern Web Applications using React and Redux
Building Modern Web Applications using React and ReduxMaxime Najim
 

What's hot (20)

Getting Started With ReactJS
Getting Started With ReactJSGetting Started With ReactJS
Getting Started With ReactJS
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
Redux vs Alt
Redux vs AltRedux vs Alt
Redux vs Alt
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
React и redux
React и reduxReact и redux
React и redux
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Redux training
Redux trainingRedux training
Redux training
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & Redux
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
 
React js
React jsReact js
React js
 
Building Modern Web Applications using React and Redux
 Building Modern Web Applications using React and Redux Building Modern Web Applications using React and Redux
Building Modern Web Applications using React and Redux
 

Viewers also liked

Starting with Reactjs
Starting with ReactjsStarting with Reactjs
Starting with ReactjsThinh VoXuan
 
006. React - Redux framework
006. React - Redux framework006. React - Redux framework
006. React - Redux frameworkBinh Quan Duc
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentationThanh Tuong
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactRob Quick
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSHoang Long
 
005. a React project structure
005. a React project structure005. a React project structure
005. a React project structureBinh Quan Duc
 
007. Redux middlewares
007. Redux middlewares007. Redux middlewares
007. Redux middlewaresBinh Quan Duc
 
Using ReactJS in AngularJS
Using ReactJS in AngularJSUsing ReactJS in AngularJS
Using ReactJS in AngularJSBoris Dinkevich
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesomeAndrew Hull
 
Deep Web
Deep WebDeep Web
Deep WebSt John
 
Social media marketing ppt
Social media marketing pptSocial media marketing ppt
Social media marketing pptSean Joan
 

Viewers also liked (19)

Starting with Reactjs
Starting with ReactjsStarting with Reactjs
Starting with Reactjs
 
006. React - Redux framework
006. React - Redux framework006. React - Redux framework
006. React - Redux framework
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Reactjs
Reactjs Reactjs
Reactjs
 
React + Redux for Web Developers
React + Redux for Web DevelopersReact + Redux for Web Developers
React + Redux for Web Developers
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
005. a React project structure
005. a React project structure005. a React project structure
005. a React project structure
 
003. ReactJS basic
003. ReactJS basic003. ReactJS basic
003. ReactJS basic
 
007. Redux middlewares
007. Redux middlewares007. Redux middlewares
007. Redux middlewares
 
Using ReactJS in AngularJS
Using ReactJS in AngularJSUsing ReactJS in AngularJS
Using ReactJS in AngularJS
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
Deep web
Deep webDeep web
Deep web
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
 
Deep Web
Deep WebDeep Web
Deep Web
 
React lecture
React lectureReact lecture
React lecture
 
Social media marketing ppt
Social media marketing pptSocial media marketing ppt
Social media marketing ppt
 

Similar to Intro to ReactJS

[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Ultimate Introduction To AngularJS
Ultimate Introduction To AngularJSUltimate Introduction To AngularJS
Ultimate Introduction To AngularJSJacopo Nardiello
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshopStacy Goh
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps. Emanuele DelBono
 
Unit Testing Express Middleware
Unit Testing Express MiddlewareUnit Testing Express Middleware
Unit Testing Express MiddlewareMorris Singer
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJSFestUA
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationAndrew Rota
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Anis Bouhachem Djer
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React TogetherSebastian Pederiva
 
Gilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesGilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesSauce Labs
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsFITC
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and ReduxBoris Dinkevich
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
"How to... React" by Luca Perna
"How to... React" by Luca Perna"How to... React" by Luca Perna
"How to... React" by Luca PernaThinkOpen
 

Similar to Intro to ReactJS (20)

[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Ultimate Introduction To AngularJS
Ultimate Introduction To AngularJSUltimate Introduction To AngularJS
Ultimate Introduction To AngularJS
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshop
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
Unit Testing Express Middleware
Unit Testing Express MiddlewareUnit Testing Express Middleware
Unit Testing Express Middleware
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-Native
 
React 101
React 101React 101
React 101
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
 
Gilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion ChallengesGilt Groupe's Selenium 2 Conversion Challenges
Gilt Groupe's Selenium 2 Conversion Challenges
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
"How to... React" by Luca Perna
"How to... React" by Luca Perna"How to... React" by Luca Perna
"How to... React" by Luca Perna
 

More from Harvard Web Working Group

Perception is Reality: Lessons Learned from User Research
Perception is Reality: Lessons Learned from User ResearchPerception is Reality: Lessons Learned from User Research
Perception is Reality: Lessons Learned from User ResearchHarvard Web Working Group
 
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...Harvard Web Working Group
 
The Process of Communication, A Practical Guide for Project Managers
The Process of Communication, A Practical Guide for Project ManagersThe Process of Communication, A Practical Guide for Project Managers
The Process of Communication, A Practical Guide for Project ManagersHarvard Web Working Group
 
Universal Design for Learning: A framework for addressing learner diversity
Universal Design for Learning: A framework for addressing learner diversityUniversal Design for Learning: A framework for addressing learner diversity
Universal Design for Learning: A framework for addressing learner diversityHarvard Web Working Group
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebHarvard Web Working Group
 
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...Harvard Web Working Group
 
Tastypie: Easy APIs to Make Your Work Easier
Tastypie: Easy APIs to Make Your Work EasierTastypie: Easy APIs to Make Your Work Easier
Tastypie: Easy APIs to Make Your Work EasierHarvard Web Working Group
 

More from Harvard Web Working Group (20)

The Internet of Things (IoT)
The Internet of Things (IoT)The Internet of Things (IoT)
The Internet of Things (IoT)
 
Perception is Reality: Lessons Learned from User Research
Perception is Reality: Lessons Learned from User ResearchPerception is Reality: Lessons Learned from User Research
Perception is Reality: Lessons Learned from User Research
 
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
 
Ui Testing with Ghost Inspector
Ui Testing with Ghost InspectorUi Testing with Ghost Inspector
Ui Testing with Ghost Inspector
 
Starting out with MongoDB
Starting out with MongoDBStarting out with MongoDB
Starting out with MongoDB
 
The Process of Communication, A Practical Guide for Project Managers
The Process of Communication, A Practical Guide for Project ManagersThe Process of Communication, A Practical Guide for Project Managers
The Process of Communication, A Practical Guide for Project Managers
 
Universal Design for Learning: A framework for addressing learner diversity
Universal Design for Learning: A framework for addressing learner diversityUniversal Design for Learning: A framework for addressing learner diversity
Universal Design for Learning: A framework for addressing learner diversity
 
UX @ Harvard's IQSS (Elizabeth Quigley)
UX @ Harvard's IQSS (Elizabeth Quigley)UX @ Harvard's IQSS (Elizabeth Quigley)
UX @ Harvard's IQSS (Elizabeth Quigley)
 
Tania Schlatter – Visual Usability
Tania Schlatter – Visual UsabilityTania Schlatter – Visual Usability
Tania Schlatter – Visual Usability
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern Web
 
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
 
Will my helicopter fit in your garage?
Will my helicopter fit in your garage?Will my helicopter fit in your garage?
Will my helicopter fit in your garage?
 
Every Screen is a Touchscreen
Every Screen is a TouchscreenEvery Screen is a Touchscreen
Every Screen is a Touchscreen
 
Tastypie: Easy APIs to Make Your Work Easier
Tastypie: Easy APIs to Make Your Work EasierTastypie: Easy APIs to Make Your Work Easier
Tastypie: Easy APIs to Make Your Work Easier
 
An Introduction to MIT's Drupal Cloud
An Introduction to MIT's Drupal CloudAn Introduction to MIT's Drupal Cloud
An Introduction to MIT's Drupal Cloud
 
Open Scholar
Open ScholarOpen Scholar
Open Scholar
 
Jumpstart Your Web App
Jumpstart Your Web AppJumpstart Your Web App
Jumpstart Your Web App
 
Draw More, Talk Less
Draw More, Talk LessDraw More, Talk Less
Draw More, Talk Less
 
Mat Marquis - JQuery Mobile
Mat Marquis - JQuery MobileMat Marquis - JQuery Mobile
Mat Marquis - JQuery Mobile
 
Curating the Open Web with Zeega
Curating the Open Web with ZeegaCurating the Open Web with Zeega
Curating the Open Web with Zeega
 

Recently uploaded

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 

Recently uploaded (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 

Intro to ReactJS

  • 1. Intro to ReactJS ! ! ! Jeff Winkler @winkler1 http://react.rocks
  • 2.
  • 3. What I'll be showing • Current approaches • React • Demos • Summarize
  • 5. JQuery! $('article.left section').click(function() { var was_selected = $(this).hasClass('section-selected'); $('article.left section').removeClass('section-selected'); if (!was_selected) { $(this).addClass('section-selected'); } }); ! $('article.right section').click(function() { $(this).toggleClass('right-selected'); if ($('section.right-selected')) { $(this).children('input.choose').toggle(); } });
  • 8. Angular ! • MVC • Angular Markup: ng-model, ng-show, ng-repeat • Dirty checking, speed limitations • Large API. • Scopes are inherited.
  • 12.
  • 13.
  • 15. Core Problem • Separation of Concerns app/partials/button.html app/css/button.css app/js/directives/button.js
  • 16. REACT
  • 17. Thesis: React is • Cohesive ! • Easy to reason about
  • 18. Quick History • Apr 2012: Instagram purchase. • June 2013 Open-sourced
  • 19. Users AirBNB, BBC, CodeAcademy, Dropbox, Facebook, Flipboard, Github, Imgur, Instagram, Khan Academy, Netflix, NYT, PayPal, Reddit, Redfin, Uber, Wired, Yahoo…
  • 20. Give it 5 Minutes
  • 21. Simple Component var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 22. JSX var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 23.
  • 24. Templating languages have a cost: they make building user interfaces harder. Doing something simple like alternating row colors in a table requires jumping through hoops in many languages. ! What we should do instead is accept that user interfaces are becoming more and more complicated and that we need a real programming language (with all of its expressive power) to build user interfaces at scale. ! (With React) instead of an oversimplified templating language, you get to use JavaScript to build abstractions and reuse code. — Pete Hunt
  • 25. JSX var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 26. JSX -> createElement var HelloMessage = React.createClass({displayName: "HelloMessage",! render: function() {! return React.createElement("div", null, "Hello ", this.props.name);! }! });! ! React.render(React.createElement(HelloMessage, {name: "John"}), mountNode);
  • 27. f(data)=virtual DOM var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 28. Using a Component var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 29. Passing props var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 30. Questions? var HelloMessage = React.createClass({! render: function() {! return <div>Hello {this.props.name}</div>;! }! });! ! React.render(<HelloMessage name="John" />, mountNode);
  • 31. State
  • 32. Timer: has secondsElapsed var Timer = React.createClass({! getInitialState() {! return {secondsElapsed: 0};! },! componentDidMount: function() {! this.interval = setInterval(this.tick, 1000);! },! tick() {! this.setState({secondsElapsed: this.state.secondsElapsed + 1});! },! render() {! return (! <div>Seconds Elapsed: {this.state.secondsElapsed}</div>! );! }! });
  • 33. Initialize State var Timer = React.createClass({! getInitialState() {! return {secondsElapsed: 0};! },! componentDidMount: function() {! this.interval = setInterval(this.tick, 1000);! },! tick() {! this.setState({secondsElapsed: this.state.secondsElapsed + 1});! },! render() {! return (! <div>Seconds Elapsed: {this.state.secondsElapsed}</div>! );! }! });
  • 34. setState() var Timer = React.createClass({! getInitialState() {! return {secondsElapsed: 0};! },! componentDidMount: function() {! this.interval = setInterval(this.tick, 1000);! },! tick() {! this.setState({secondsElapsed: this.state.secondsElapsed + 1});! },! render() {! return (! <div>Seconds Elapsed: {this.state.secondsElapsed}</div>! );! }! });
  • 35. render var Timer = React.createClass({! getInitialState() {! return {secondsElapsed: 0};! },! componentDidMount: function() {! this.interval = setInterval(this.tick, 1000);! },! tick() {! this.setState({secondsElapsed: this.state.secondsElapsed + 1});! },! render() {! return (! <div>Seconds Elapsed: {this.state.secondsElapsed}</div>! );! }! });
  • 37. Composition var PictureOfTheDay = require('./Components/PictureOfTheDay.js');! var DateBrowser = require('./Components/DateBrowser.js');! var Title = require('./Components/Title.js');! ! var SpacePics = React.createClass ({! render() {! return (! <div>! <Title title={this.state.title} />! <PictureOfTheDay picture={this.state.picture} />! <DateBrowser date={this.state.date} onChange={this._onDateChange} />! </div>! );!
  • 38. require() var PictureOfTheDay = require('./Components/PictureOfTheDay.js');! var DateBrowser = require('./Components/DateBrowser.js');! var Title = require('./Components/Title.js');! ! var SpacePics = React.createClass ({! render() {! return (! <div>! <Title title={this.state.title} />! <PictureOfTheDay picture={this.state.picture} />! <DateBrowser date={this.state.date} onChange={this._onDateChange} />! </div>! );!
  • 39. Passing data to children var PictureOfTheDay = require('./Components/PictureOfTheDay.js');! var DateBrowser = require('./Components/DateBrowser.js');! var Title = require('./Components/Title.js');! ! var SpacePics = React.createClass ({! render() {! return (! <div>! <Title title={this.state.title} />! <PictureOfTheDay picture={this.state.picture} />! <DateBrowser date={this.state.date} onChange={this._onDateChange} />! </div>! );!
  • 40. Data from parent to child
  • 41.
  • 42. Need-to-know var PictureOfTheDay = require('./Components/PictureOfTheDay.js');! var DateBrowser = require('./Components/DateBrowser.js');! var Title = require('./Components/Title.js');! ! var SpacePics = React.createClass ({! render() {! return (! <div>! <Title title={this.state.title} />! <PictureOfTheDay picture={this.state.picture} />! <DateBrowser date={this.state.date} onChange={this._onDateChange} />! </div>! );!
  • 44. Demos Virtual DOM! Creating a component ReactNative
  • 48. Our script • Create new: Apples, Bread • Check off Apples • Switch between tabs
  • 51. React
  • 52.
  • 53. Demos Virtual DOM Creating a component! ReactNative
  • 54. Demo #2: Encapsulation • Internal state • UI actions • refactoring
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Hello World • import React from 'react';
 
 export default class WhosAsleepScore extends React.Component {
 render() {
 return (
 <h1>Hello, world!</h1>
 );
 }
 }
  • 63. code • import React from 'react';
 
 export default class WhosAsleepScore extends React.Component {
 constructor(props) {
 super(props);
 this.state={count:0};
 }
 render() {
 let {count}= this.state;
 return (
 <h1>Who's Asleep score: {count}</h1>
 );
 }
 }
  • 67. End Result import React from 'react';
 export default class WhosAsleepScore extends React.Component {
 constructor(props) {
 super(props);
 this.state = {count: 0};
 }
 addSleeper() {
 this.setState({count:this.state.count+1});
 }
 
 render() {
 return (
 <div>
 <img src='ct.png' onClick={this.addSleeper.bind(this)} />
 <span style={countStyle}>{this.state.count}</span>
 </div>
 );
 }
 }
  • 68. Demos Virtual DOM Creating a component! ReactNative
  • 74.
  • 75. // if we have an error
 if (this.state.error !== null) {
 innerNode = <ErrorWidget title="NASA API Error" message={this.state.error} />;
 title = 'Error';
 } If Error
  • 76. ErrorWidget • var React = require('react-native');
 var {
 StyleSheet,
 Text,
 View,
 } = React;
 
 class ErrorWidget extends React.Component {
 render() {
 return (
 <View style={styles.container}>
 <Text style={styles.title}>{this.props.title}</Text>
 <Text style={styles.message}>{this.props.message}</ Text>
 </View>
 );
 }
 }
  • 77.
  • 78. propTypes class ErrorWidget extends React.Component {! propTypes: {! message: React.PropTypes.string.isRequired,! title: React.PropTypes.string.isRequired,! },
 render() {
 return (
 <View style={styles.container}>
 <Text style={styles.title}>{this.props.title}</Text>
 <Text style={styles.message}>{this.props.message}</Text>
 </View>
 );
 }
 }
  • 79. Loading // if we don't have a picture
 else if (this.state.picture === null) {
 innerNode = <Loading title="Getting Image..." />;
 title = 'Loading...';
 }!
  • 80. Loading Widget • var React = require('react-native');
 var {
 StyleSheet,
 ActivityIndicatorIOS,
 Text,
 View,
 } = React;
 
 class Loading extends React.Component {
 render() {
 return (
 <View style={styles.container}>
 <ActivityIndicatorIOS animating={true} />
 <Text style={styles.title}>{this.props.title}</Text>
 </View>
 );
 }
 }
  • 81. else: Picture // if we have a picture
 else {
 innerNode = <PictureOfTheDay picture={this.state.picture} />;
 title = this.state.picture.title;
 }!
  • 83.
  • 84.
  • 85. Demos Virtual DOM Creating a component ReactNative
  • 89. Time
  • 90.
  • 91. Summary React is easy to reason about
  • 92.
  • 93. Where to go from here? • http://facebook.github.io/react/ • search “Thinking in React” !