SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Philos.io
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
Darren Cruse
 
React js basics
React js basicsReact js basics
React js basics
Maulik Shah
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
Diluka Wittahachchige
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React Native
Tadeu Zagallo
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
Ahmed rebai
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
Commit University
 
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
 
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
Polidea
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
Divyang Bhambhani
 
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
500Tech
 
Internal workshop react-js-mruiz
Internal workshop react-js-mruizInternal workshop react-js-mruiz
Internal workshop react-js-mruiz
Miguel Ruiz Rodriguez
 
Reactjs
Reactjs Reactjs
Reactjs
Neha Sharma
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
Software Guru
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
kiranabburi
 
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”
GlobalLogic Ukraine
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
Oswald Campesato
 

What's hot (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
 

Similar to A Closer Look At React Native

From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
jubilem
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer0983676660
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
Jens Ravens
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
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...
Rob Tweed
 
OneRing @ OSCamp 2010
OneRing @ OSCamp 2010OneRing @ OSCamp 2010
OneRing @ OSCamp 2010
Qiangning Hong
 
SignalR
SignalRSignalR
SignalR
LearningTech
 
MunichJS - node.js - from the beginning
MunichJS - node.js - from the beginningMunichJS - node.js - from the beginning
MunichJS - node.js - from the beginning
Robert Prediger
 
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
Budh Ram Gurung
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
Matt Raible
 
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
Java User Group Latvia
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
Steven Cooper
 
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 developerEdureka!
 
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!
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini Cordova
Ayman Mahfouz
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
Stfalcon Meetups
 
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
Yevgeniy Brikman
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín
 

Similar to 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
 

Recently uploaded

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 

Recently uploaded (20)

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 

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 ...