SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
1
A Closer Look At
React Native
Ian Wang
Web Developer at Codementor.io
@ianwang36
2
What Is React Native
“ React Native enables you to
build world-class application
experiences on native
platforms using a consistent
developer experience based
on JavaScript and React.
- React Native Website
3
What Is React Native
“ React Native enables you to
build world-class application
experiences on native
platforms using a consistent
developer experience based
on JavaScript and React.
- React Native Website
4
No HTML
No Browser
No WebView
Completely powered by
JavaScript
5
How it Works
React.js
JavaScript 
Core
ReactNative 
Bridge
Native
Method
UI ThreadJS Thread
Native
Async &
Batched
communication
7
How to Use It
Components
Style &
Layout
APIs
8
Components
<TouchableHighlight
onPress={() => { onPress(user, chat); }}>
<View>
<Image source={require('./image/avatar.png')} />
<View>
<View>
<Text>{ user.name }</Text>
<Text>{ chatDate }</Text>
</View>
<Text>
{ messageContent }
</Text>
</View>
</TouchableHighlight>
TouchableHighlight, View, Image, Text
mockup
9
Components
getInitialState() {
return {
dataSource: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
};
},
componentWillReceiveProps(nextProps) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(
nextProps.myData
)
});
},
render() {
<ListView
ref="scrollListView"
dataSource={this.state.dataSource}
renderRow={this._renderRow}
onScroll={this._handleOnScroll} />
}
ListView
10
Components
renderScene(route, navigator) {
if(route.component) {
var props = route.passProps;
return React.createElement(route.component, {
...props
});
}
},
render() {
return (
<Navigator
initialRoute={{
component: MainEntryPoint,
title: 'Codementor'
}}
renderScene={this.renderScene} />
)
}
///////////////
this.props.navigator.push({
component,
title,
passProps
});
// pop();
// jumpBack();
Navigator
11
CSS in JS (inline css)
problem with CSS at scale:
Style & Layout
Global Namespace
Minification
Sharing Constants
Dependencies
https://speakerdeck.com/vjeux/react-css-in-js
12
Style & Layout
let styles = StyleSheet.create({
chatRowName: {
flex: 1,
color: "#333333",
textAlign: 'left',
},
chatRowTimeText:{
width: 60,
color: '#b7b8b9',
textAlign: 'right',
fontSize: 12,
},
});
<TouchableHighlight
underlayColor="#f3f3f3">
<View>
<Text style={styles.chatRowName}>{user.name}</Text>
<Text style={styles.chatRowDate}>{chatDate}</Text>
</View>
</TouchableHighlight>
13
Style & Layout
How to reimplement CSS on native ???
CSS Box Model (margin, padding, border)
CSS Visual Formatting Model (display, position, float)
Top
Left
Width
Height
14
Extreme TDD
Style & Layout
from React.js Conf 2015 Keynote 2 - A Deep Dive into React Native
15
Extreme TDD
Fail. Fix. Iterate.
Style & Layout
from React.js Conf 2015 Keynote 2 - A Deep Dive into React Native
16
APIs
Alert
Alert.alert(
"Send message to Norman Kurry?",
"We've just notified ...", [{
text: negativeText,
onPress: negativeOnPress
}, {
text: positiveText,
onPress: positiveOnPress
}]
);
17
APIs
Fetch
fetch('https://mywebsite.com/endpoint.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstParam: 'yourValue',
secondParam: 'yourOtherValue',
})
})
.then((response) => response.text())
.then((responseText) => {
console.log(responseText);
})
.catch((error) => {
console.warn(error);
});
18
APIs
Push Notification
PushNotification.requestPermissions();
PushNotification.addEventListener(
// get deviceToken
"register", this._didRegistered
);
PushNotification.addEventListener(
// get notification's context
"notification", this._handleNotification
);
Mobile
Login
Store
Token
Poke
SNS
Send to
Device
mobile API API SNS
19
Debugging
20
Testing
import React, { View, Text, StyleSheet } from 'react-native';
import { shallow } from 'enzyme';
import { expect } from 'chai';
const Test = React.createClass({
render() {
return (
<View>
<Text>enzyme</Text>
<Text>rules</Text>
</View>
)
}
});
describe('<Test />', () => {
it('it should render 1 view component', () => {
const wrapper = shallow(<Test/>);
expect(wrapper.find(View)).to.have.length(1);
});
it('it should render 2 text components', () => {
const wrapper = shallow(<Test/>);
expect(wrapper.find(Text)).to.have.length(2);
});
});
21
“ Upgrading could be a pain in
the ass, but I guess it's worth it.  
                                   Ian Wang, 2016
22
Todos
Over-the-air update (react-native-code-push)
Tracking (react-native-mixpanel)
Testing (Enzyme)
Platform specific UIs??
Redux in mind (Fluxxor bye)
Routing management
...
23
Q&A
Thanks

Weitere ähnliche Inhalte

Was ist angesagt?

Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
 

Was ist angesagt? (20)

React JS Belgium Touch Base - React, Flux, React Native
React JS Belgium Touch Base - React, Flux, React NativeReact JS Belgium Touch Base - React, Flux, React Native
React JS Belgium Touch Base - React, Flux, React Native
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
 
React js basics
React js basicsReact js basics
React js basics
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React Native
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
 
React native: building native iOS apps with javascript
React native: building native iOS apps with javascriptReact native: building native iOS apps with javascript
React native: building native iOS apps with javascript
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 
Internal workshop react-js-mruiz
Internal workshop react-js-mruizInternal workshop react-js-mruiz
Internal workshop react-js-mruiz
 
Reactjs
Reactjs Reactjs
Reactjs
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
 
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
 

Ähnlich wie A Closer Look At React Native

Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer
0983676660
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
Edureka!
 

Ähnlich wie A Closer Look At React Native (20)

From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
 
OneRing @ OSCamp 2010
OneRing @ OSCamp 2010OneRing @ OSCamp 2010
OneRing @ OSCamp 2010
 
SignalR
SignalRSignalR
SignalR
 
MunichJS - node.js - from the beginning
MunichJS - node.js - from the beginningMunichJS - node.js - from the beginning
MunichJS - node.js - from the beginning
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web Applications
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini Cordova
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
 
Frontend. Global domination.
Frontend. Global domination.Frontend. Global domination.
Frontend. Global domination.
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
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
 

Kürzlich hochgeladen

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Kürzlich hochgeladen (20)

%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

A Closer Look At React Native

  • 1. 1 A Closer Look At React Native Ian Wang Web Developer at Codementor.io @ianwang36
  • 2. 2 What Is React Native “ React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. - React Native Website
  • 3. 3 What Is React Native “ React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. - React Native Website
  • 4. 4 No HTML No Browser No WebView Completely powered by JavaScript
  • 7. 7 How to Use It Components Style & Layout APIs
  • 8. 8 Components <TouchableHighlight onPress={() => { onPress(user, chat); }}> <View> <Image source={require('./image/avatar.png')} /> <View> <View> <Text>{ user.name }</Text> <Text>{ chatDate }</Text> </View> <Text> { messageContent } </Text> </View> </TouchableHighlight> TouchableHighlight, View, Image, Text mockup
  • 9. 9 Components getInitialState() { return { dataSource: new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 }); }; }, componentWillReceiveProps(nextProps) { this.setState({ dataSource: this.state.dataSource.cloneWithRows( nextProps.myData ) }); }, render() { <ListView ref="scrollListView" dataSource={this.state.dataSource} renderRow={this._renderRow} onScroll={this._handleOnScroll} /> } ListView
  • 10. 10 Components renderScene(route, navigator) { if(route.component) { var props = route.passProps; return React.createElement(route.component, { ...props }); } }, render() { return ( <Navigator initialRoute={{ component: MainEntryPoint, title: 'Codementor' }} renderScene={this.renderScene} /> ) } /////////////// this.props.navigator.push({ component, title, passProps }); // pop(); // jumpBack(); Navigator
  • 11. 11 CSS in JS (inline css) problem with CSS at scale: Style & Layout Global Namespace Minification Sharing Constants Dependencies https://speakerdeck.com/vjeux/react-css-in-js
  • 12. 12 Style & Layout let styles = StyleSheet.create({ chatRowName: { flex: 1, color: "#333333", textAlign: 'left', }, chatRowTimeText:{ width: 60, color: '#b7b8b9', textAlign: 'right', fontSize: 12, }, }); <TouchableHighlight underlayColor="#f3f3f3"> <View> <Text style={styles.chatRowName}>{user.name}</Text> <Text style={styles.chatRowDate}>{chatDate}</Text> </View> </TouchableHighlight>
  • 13. 13 Style & Layout How to reimplement CSS on native ??? CSS Box Model (margin, padding, border) CSS Visual Formatting Model (display, position, float) Top Left Width Height
  • 14. 14 Extreme TDD Style & Layout from React.js Conf 2015 Keynote 2 - A Deep Dive into React Native
  • 15. 15 Extreme TDD Fail. Fix. Iterate. Style & Layout from React.js Conf 2015 Keynote 2 - A Deep Dive into React Native
  • 16. 16 APIs Alert Alert.alert( "Send message to Norman Kurry?", "We've just notified ...", [{ text: negativeText, onPress: negativeOnPress }, { text: positiveText, onPress: positiveOnPress }] );
  • 17. 17 APIs Fetch fetch('https://mywebsite.com/endpoint.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ firstParam: 'yourValue', secondParam: 'yourOtherValue', }) }) .then((response) => response.text()) .then((responseText) => { console.log(responseText); }) .catch((error) => { console.warn(error); });
  • 18. 18 APIs Push Notification PushNotification.requestPermissions(); PushNotification.addEventListener( // get deviceToken "register", this._didRegistered ); PushNotification.addEventListener( // get notification's context "notification", this._handleNotification ); Mobile Login Store Token Poke SNS Send to Device mobile API API SNS
  • 20. 20 Testing import React, { View, Text, StyleSheet } from 'react-native'; import { shallow } from 'enzyme'; import { expect } from 'chai'; const Test = React.createClass({ render() { return ( <View> <Text>enzyme</Text> <Text>rules</Text> </View> ) } }); describe('<Test />', () => { it('it should render 1 view component', () => { const wrapper = shallow(<Test/>); expect(wrapper.find(View)).to.have.length(1); }); it('it should render 2 text components', () => { const wrapper = shallow(<Test/>); expect(wrapper.find(Text)).to.have.length(2); }); });
  • 21. 21 “ Upgrading could be a pain in the ass, but I guess it's worth it.                                      Ian Wang, 2016
  • 22. 22 Todos Over-the-air update (react-native-code-push) Tracking (react-native-mixpanel) Testing (Enzyme) Platform specific UIs?? Redux in mind (Fluxxor bye) Routing management ...