SlideShare a Scribd company logo
1 of 45
Download to read offline
React Native: Hype, Reality
and basics
Who am I?
● Google Certified Associate Android Developer.
● Founding Member, Lead Full Stack and
Embedded Firmware Engineer @ AutoNxt
Automation.
● Tech Speaker at Google Dev Fest 2017.
● Recognized Developer and Contributor @ XDA
Developers
● Open source enthusiast, contributor and Tech
Speaker.
ZETAYU Scrap Karle EZY
Native Programming
Pros
● Best performance, easy access to HW
and sensors.
● Wide range of resources and Tutorials.
● Large repository of supported libraries
and SDKs.
● Acceptance to App store or Play store
without haste.
Source: medium.com
Cons
● Handling different codebase.
● Support for different OS
● Support for wide range of devices.
● UI/UX and different terminologies.
● High development cost due to
multiple resources involved.
Source: medium.com
Why React Native?
● Single codebase across.
● Javascript at the heart.
● Near native performance.
● Hot Reloading.
● Access to platform specific code.
● Large community and support for widely
used modules (maps, firebase, etc.) Source: medium.com
Quick Comparison
● Java or Kotlin or Swift or C#
● XML, Storyboard, etc.
● XML attributes, Constraints.
● Classes or Screens
● Retrofit, Alamofire, Volley, etc.
● Platform Specific access
● Javascript
● JSX
● Flexbox
● Components
● Fetch API
● Platform specific access
Let’s Dive Deep!
What’s Functional Programming?
function double (arr) {
let results = []
for (let i = 0; i < arr.length; i++){
results.push(arr[i] * 2)
}
return results
}
function double (arr) {
return arr.map((item) => item * 2)
}
Imperative Programming
Declarative Programming
Declarative Pure functions
“A function is only pure if, given the same
input, it will always produce the same
output.”
Math.random(); // => 0.4011148700956255
Math.random(); // => 0.8533405303023756
Math.random(); // => 0.3550692005082965
const double = x => x * 2;
double(5); // => 10
double(5); // => 10
double(5); // => 10
Pure
Impure
Other FP Concepts
● No Shared State.
● Immutability.
● No Side Effects.
● Reusability via Higher Order Functions.
● Reliance on pure functions like map(),
reduce(), filter()
Source: medium.com
What is React Native?
● A JavaScript library (and not a framework) working
hand in hand with Native Code.
● Uses JavaScriptCore to run JS layer over native code.
JS Thread
React Native
Bridge
Main
Thread
Yoga
Declare
Components.
Duplex
Communication.
Populate
Components.
Handle layout
rendering
calculations
JSX
import React, { Component } from 'react';
import { Text } from 'react-native';
export default class HelloWorldApp extends Component {
render() {
return (
<Text>Hello world!</Text> JSX
);
}
}
● Statically typed programming language used to represent
Views in RN.
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
const element = (
<Text> Hello, {formatName(user)}! </Text> JSX
);
React Components
What are React Components?
● Simple JavaScript functions (or
classes) returning Views.
● They can be Stateful(classes) or
Stateless(functional).
● Accept data(props) and describes UI
based on business logic.
import React, { Component } from 'react';
import { Text } from 'react-native';
export default class HelloWorldApp
extends Component {
render() {
return (
<Text>Hello world!</Text>
);
}
}
Stateful Component
Source: medium.com
class HelloWorldApp extends Component {
constructor(props) {
super(props)
this.state = {
data: Hello world
}
}
render() {
return (
<Text>{this.state.data}!</Text>
);
}
} Class Component (Stateful)
State
Functional Component (Stateless)
const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => (
<View style={{flexDirection: 'row'}}>
<View style={{flex: 1}}>
<Image source={require('../images/home.png')}/>
<Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text>
</View>
</View>
);
Props
State and Props
Component Props
● Props are properties passed
between components.
● Both class and functional
component accept props.
● Can be accessed using this.props or
by dereferencing.
● Similar to the extras passed via
intent in Android
const HouseCard = (props) => (
<View style={{flexDirection: 'row'}}>
<Text style={{fontSize: 22, marginLeft:
8}}>{props.deviceId}</Text>
</View>
);
const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => (
<View style={{flexDirection: 'row'}}>
<View style={{flex: 1}}>
<Image source={require('../images/home.png')}/>
<Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text>
</View>
</View>
);
render() {
<HouseCard onNewHouseSelection={this.onNewHouseSelection}
selectedHouse={this.state.selectedHouse}
deviceId={this.state.selectedHouse}
/>
}
Component State
● State is a temporary data storage
for component.
● Not to be directly mutated. Use
this.setState() instead.
● this.state should be assigned only
once in the constructor.
● State changes causes re-rendering
inside component.
class HelloWorldApp extends
Component {
constructor(props) {
super(props)
this.state = {
data: Hello world
}
}
}
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {date: new Date()};
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
1000
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
tick() {
this.setState({
date: new Date()
});
}
render() {
return (
<View>
<Text>Hello, world!</Text>
<Text>It is
{this.state.date.toLocaleTimeString()}.</Text
>
</View>
);
}
}
Specific
Re-render
Source: reactjs.org
Component Lifecycle
First Render
Re-render
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {date: new Date()};
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
1000
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
tick() {
this.setState({
date: new Date()
});
}
render() {
return (
<View>
<Text>Hello, world!</Text>
<Text>It is
{this.state.date.toLocaleTimeString()}.</Text
>
</View>
);
}
}
Styling
Welcome to Flexbox (LinearLayout clone)
● RN uses flexbox for styling.
● Flexbox sits perfectly with
Android’s LinearLayout analogy.
● Styles are represented in the
form of simple JS objects.
● Attributes are written with
camelCase notations.
● { flex: 1 }
● { flexDirection: ‘row’ or ‘column’ }
● { justifyContent: ‘center’, alignItems:
‘center’}
● marginTop, marginBottom,
marginLeft, marginRight, margin
● paddingTop, paddingBottom,
paddingRight, paddingLeft, padding.
● { backgroundColor: ‘black’ }
● Height and width=match_parent, weight
● android:orientation= horiz. Or vertical
● Layout_centerInParent = true,
layout_gravity = center
● marginTop, marginBottom, marginLeft,
marginRight, margin
● paddingTop, paddingBottom,
paddingRight, paddingLeft, padding.
● android:background=”#000000”
const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => (
<View style={{flexDirection: 'row'}}>
<View style={{flex: 1}}>
<Image source={require('../images/home.png')}/>
<Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text>
</View>
</View>
);
Networking
fetch('https://www.example.com', {
method: 'POST',
body: JSON.stringify({
username: 'vishal', password: '#4@!94'})
}).then(data => {
return data.json()
}).then(jsonData => {
// play with it.....
const fullName = jsonData.fullName
});
Ref
render() {
<View>
<TextInput ref={(ref) => this.input = ref} />
</View>
}
this.input.clear();
this.input.isFocused();
What’s Next?
● Build cross platform modular apps using React + Redux.
● Start Web dev using ReactJS.
● Build desktop apps using React + Electron.
● Build mobile, web and desktop version of your app, keeping the business
logic code, *exactly same*.
● Build strict and tightly coupled apps using Typescript or Flow.
● Decide if Pure Native is suitable or React Native.
Thank You!
Twitter: @vishal_AF
GitHub: vishal-android-freak
LinkedIn: vishalaf
Email: vishal@autonxt.in

More Related Content

What's hot

[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickICS
 
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
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥Remo Jansen
 
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald PehlGWTcon
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
React Workshop: Core concepts of react
React Workshop: Core concepts of reactReact Workshop: Core concepts of react
React Workshop: Core concepts of reactImran Sayed
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouRobert Cooper
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IICS
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentICS
 
React – Structure Container Component In Meteor
 React – Structure Container Component In Meteor React – Structure Container Component In Meteor
React – Structure Container Component In MeteorDesignveloper
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
 

What's hot (20)

Power tools in Java
Power tools in JavaPower tools in Java
Power tools in Java
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
 
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
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
 
React & redux
React & reduxReact & redux
React & redux
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
React render props
React render propsReact render props
React render props
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
React Workshop: Core concepts of react
React Workshop: Core concepts of reactReact Workshop: Core concepts of react
React Workshop: Core concepts of react
 
The Road To Redux
The Road To ReduxThe Road To Redux
The Road To Redux
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than You
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI development
 
React – Structure Container Component In Meteor
 React – Structure Container Component In Meteor React – Structure Container Component In Meteor
React – Structure Container Component In Meteor
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 

Similar to React native

React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React TogetherSebastian Pederiva
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
GDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSGDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSPratik Majumdar
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
 
JSAnkara Swift v React Native
JSAnkara Swift v React NativeJSAnkara Swift v React Native
JSAnkara Swift v React NativeMuhammed Demirci
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsMatteo Manchi
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react jsdhanushkacnd
 
N Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeAnton Kulyk
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 

Similar to React native (20)

ReactJS
ReactJSReactJS
ReactJS
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
GDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSGDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJS
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
JSAnkara Swift v React Native
JSAnkara Swift v React NativeJSAnkara Swift v React Native
JSAnkara Swift v React Native
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
React/Redux
React/ReduxReact/Redux
React/Redux
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react js
 
N Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React Native
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 

Recently uploaded

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Salam Al-Karadaghi
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptxBasil Achie
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptssuser319dad
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...NETWAYS
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...NETWAYS
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...NETWAYS
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...NETWAYS
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝soniya singh
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AITatiana Gurgel
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)Basil Achie
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...henrik385807
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxFamilyWorshipCenterD
 

Recently uploaded (20)

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.ppt
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
 
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AI
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
 

React native

  • 1. React Native: Hype, Reality and basics
  • 2. Who am I? ● Google Certified Associate Android Developer. ● Founding Member, Lead Full Stack and Embedded Firmware Engineer @ AutoNxt Automation. ● Tech Speaker at Google Dev Fest 2017. ● Recognized Developer and Contributor @ XDA Developers ● Open source enthusiast, contributor and Tech Speaker.
  • 5. Pros ● Best performance, easy access to HW and sensors. ● Wide range of resources and Tutorials. ● Large repository of supported libraries and SDKs. ● Acceptance to App store or Play store without haste. Source: medium.com
  • 6. Cons ● Handling different codebase. ● Support for different OS ● Support for wide range of devices. ● UI/UX and different terminologies. ● High development cost due to multiple resources involved. Source: medium.com
  • 7. Why React Native? ● Single codebase across. ● Javascript at the heart. ● Near native performance. ● Hot Reloading. ● Access to platform specific code. ● Large community and support for widely used modules (maps, firebase, etc.) Source: medium.com
  • 8. Quick Comparison ● Java or Kotlin or Swift or C# ● XML, Storyboard, etc. ● XML attributes, Constraints. ● Classes or Screens ● Retrofit, Alamofire, Volley, etc. ● Platform Specific access ● Javascript ● JSX ● Flexbox ● Components ● Fetch API ● Platform specific access
  • 11. function double (arr) { let results = [] for (let i = 0; i < arr.length; i++){ results.push(arr[i] * 2) } return results } function double (arr) { return arr.map((item) => item * 2) } Imperative Programming Declarative Programming
  • 12. Declarative Pure functions “A function is only pure if, given the same input, it will always produce the same output.”
  • 13. Math.random(); // => 0.4011148700956255 Math.random(); // => 0.8533405303023756 Math.random(); // => 0.3550692005082965 const double = x => x * 2; double(5); // => 10 double(5); // => 10 double(5); // => 10 Pure Impure
  • 14. Other FP Concepts ● No Shared State. ● Immutability. ● No Side Effects. ● Reusability via Higher Order Functions. ● Reliance on pure functions like map(), reduce(), filter() Source: medium.com
  • 15. What is React Native?
  • 16. ● A JavaScript library (and not a framework) working hand in hand with Native Code. ● Uses JavaScriptCore to run JS layer over native code. JS Thread React Native Bridge Main Thread Yoga Declare Components. Duplex Communication. Populate Components. Handle layout rendering calculations
  • 17. JSX
  • 18. import React, { Component } from 'react'; import { Text } from 'react-native'; export default class HelloWorldApp extends Component { render() { return ( <Text>Hello world!</Text> JSX ); } } ● Statically typed programming language used to represent Views in RN.
  • 19. function formatName(user) { return user.firstName + ' ' + user.lastName; } const user = { firstName: 'Harper', lastName: 'Perez' }; const element = ( <Text> Hello, {formatName(user)}! </Text> JSX );
  • 21. What are React Components? ● Simple JavaScript functions (or classes) returning Views. ● They can be Stateful(classes) or Stateless(functional). ● Accept data(props) and describes UI based on business logic. import React, { Component } from 'react'; import { Text } from 'react-native'; export default class HelloWorldApp extends Component { render() { return ( <Text>Hello world!</Text> ); } } Stateful Component Source: medium.com
  • 22. class HelloWorldApp extends Component { constructor(props) { super(props) this.state = { data: Hello world } } render() { return ( <Text>{this.state.data}!</Text> ); } } Class Component (Stateful) State
  • 23. Functional Component (Stateless) const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => ( <View style={{flexDirection: 'row'}}> <View style={{flex: 1}}> <Image source={require('../images/home.png')}/> <Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text> </View> </View> ); Props
  • 25. Component Props ● Props are properties passed between components. ● Both class and functional component accept props. ● Can be accessed using this.props or by dereferencing. ● Similar to the extras passed via intent in Android const HouseCard = (props) => ( <View style={{flexDirection: 'row'}}> <Text style={{fontSize: 22, marginLeft: 8}}>{props.deviceId}</Text> </View> );
  • 26. const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => ( <View style={{flexDirection: 'row'}}> <View style={{flex: 1}}> <Image source={require('../images/home.png')}/> <Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text> </View> </View> ); render() { <HouseCard onNewHouseSelection={this.onNewHouseSelection} selectedHouse={this.state.selectedHouse} deviceId={this.state.selectedHouse} /> }
  • 27. Component State ● State is a temporary data storage for component. ● Not to be directly mutated. Use this.setState() instead. ● this.state should be assigned only once in the constructor. ● State changes causes re-rendering inside component. class HelloWorldApp extends Component { constructor(props) { super(props) this.state = { data: Hello world } } }
  • 28. class Clock extends React.Component { constructor(props) { super(props); this.state = {date: new Date()}; } componentDidMount() { this.timerID = setInterval( () => this.tick(), 1000 ); } componentWillUnmount() { clearInterval(this.timerID); } tick() { this.setState({ date: new Date() }); } render() { return ( <View> <Text>Hello, world!</Text> <Text>It is {this.state.date.toLocaleTimeString()}.</Text > </View> ); } }
  • 31.
  • 33. class Clock extends React.Component { constructor(props) { super(props); this.state = {date: new Date()}; } componentDidMount() { this.timerID = setInterval( () => this.tick(), 1000 ); } componentWillUnmount() { clearInterval(this.timerID); } tick() { this.setState({ date: new Date() }); } render() { return ( <View> <Text>Hello, world!</Text> <Text>It is {this.state.date.toLocaleTimeString()}.</Text > </View> ); } }
  • 35. Welcome to Flexbox (LinearLayout clone) ● RN uses flexbox for styling. ● Flexbox sits perfectly with Android’s LinearLayout analogy. ● Styles are represented in the form of simple JS objects. ● Attributes are written with camelCase notations.
  • 36. ● { flex: 1 } ● { flexDirection: ‘row’ or ‘column’ } ● { justifyContent: ‘center’, alignItems: ‘center’} ● marginTop, marginBottom, marginLeft, marginRight, margin ● paddingTop, paddingBottom, paddingRight, paddingLeft, padding. ● { backgroundColor: ‘black’ } ● Height and width=match_parent, weight ● android:orientation= horiz. Or vertical ● Layout_centerInParent = true, layout_gravity = center ● marginTop, marginBottom, marginLeft, marginRight, margin ● paddingTop, paddingBottom, paddingRight, paddingLeft, padding. ● android:background=”#000000”
  • 37. const HouseCard = ({deviceId, selectedHouse, onNewHouseSelection}) => ( <View style={{flexDirection: 'row'}}> <View style={{flex: 1}}> <Image source={require('../images/home.png')}/> <Text style={{fontSize: 22, marginLeft: 8}}>{deviceId}</Text> </View> </View> );
  • 39.
  • 40. fetch('https://www.example.com', { method: 'POST', body: JSON.stringify({ username: 'vishal', password: '#4@!94'}) }).then(data => { return data.json() }).then(jsonData => { // play with it..... const fullName = jsonData.fullName });
  • 41. Ref
  • 42. render() { <View> <TextInput ref={(ref) => this.input = ref} /> </View> } this.input.clear(); this.input.isFocused();
  • 43. What’s Next? ● Build cross platform modular apps using React + Redux. ● Start Web dev using ReactJS. ● Build desktop apps using React + Electron. ● Build mobile, web and desktop version of your app, keeping the business logic code, *exactly same*. ● Build strict and tightly coupled apps using Typescript or Flow. ● Decide if Pure Native is suitable or React Native.
  • 44.
  • 45. Thank You! Twitter: @vishal_AF GitHub: vishal-android-freak LinkedIn: vishalaf Email: vishal@autonxt.in