SlideShare a Scribd company logo
1 of 34
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Introduction to React Native
Nader Dabit
Developer Advocate, AWS Mobile
Pop-up Loft
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Prerequisites
• JavaScript, preferably ES6 / ES2015
• Knowledge of how to use the command line
• Basic understanding of npm & how it works
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Environment
• Node – version >= 4
• Watchman (if using React Native CLI)
• Xcode (to run iOS simulator)
• Genymotion or Android Studio (to run on Android Emulator)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is React Native?
• Built using React
• Build cross platform applications using JavaScript
• Target not only iOS & Android, but also Apple TV, VR, AR, Windows, &
Desktop
• Released March 2015
• Rapidly gaining in popularity & adoption
• Learn once write anywhere
• Real world projects typically see 80% – 95% code reuse
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Who’s using React Native
• Facebook
• Instagram
• Walmart
• Airbnb
• Skype
• Baidu
• Tesla
• Adidas
• Discord
• Wix
• Bloomberg
• JD.com
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why React Native
• Faster speed of development
• Lower cost of development
• Code reuse
• Easier to find developers
• Ship across multiple platforms
• Possible to ship over the air updates bypassing App Store / Play Store
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does React Native Work?
• JavaScript is bundled & minified using Babel (built in)
• Separate threads for UI, layout, and JavaScript
• Threads communicate asynchronously through the native bridge
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does React Native Work?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native API
View
Text
ScrollView
Image
TextInput
Switch
Over 30 UI Primitives
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native API
View == div
Text == span / p / h*
ScrollView == div + styling
Image == img
TextInput == input
Mapping to Web UI primitives
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native API
import {
View
Text
ScrollView
Image
TextInput
Switch
} from ‘react-native’
Primitives not globally in scope, must be imported
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native API
CameraRoll
Keyboard
NetInfo
Vibration
PanResponder
Device APIs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native vs Web
• Different primitives
• Styling
• Most browser APIs do not exist
• Some browser APIs polyfilled (geolocation, fetch, timers,
console)
• Navigation
• Mobile UI / UX
• Native IDEs / configuration
• Deployment
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native vs Web
• Unlike web, not every component has every interaction
• Handful of “touchable” components
• Button, TouchableHighlight, TouchableOpacity,
TouchableWithoutFeedback
• Create custom touchable components with PanResponder API
Event handling
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native vs Web
• Based on CSS styles
• Layout is done with FlexBox
• Style prop can be one or an array of styles
• Use StyleSheet API for perf optimization
• Makes it possible to refer to styles by ID instead of creating a new style
object every time.
• Allows to send the style only once through the bridge. All subsequent uses
are going to refer an id (not implemented yet).
Styling
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native vs Web
JS Objects or inline styles
Styling
const styles = {
container: {
margin: 20,
backgroundColor: ‘red’
}
}
<View
style={styles.container}
/>
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
React Native vs Web
Styling - StyleSheet
import { StyleSheet } from ‘react-native’
const styles = StyleSheet.create({
container: {
margin: 20,
backgroundColor: ‘red’
}
})
<View style={styles.container} />
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Creating a new React Native Project
2 Main Options
React Native CLI
Create React Native App CLI
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Creating a new React Native Project
Create React Native App CLI
• Builds without native projects & code
• Native code not configurable
• Will run without all SDKs & IDEs installed
• Great for newer developers
• Includes features like Camera, Location, Push Notifications, Social
Authentication, Accelerometer, File System, & Image Picker
configured out of the box
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Creating a new React Native Project
React Native CLI
• Builds with native projects & code
• Native code configurable
• Needs proper environment setup in order to run
• Does not include some important APIs without additional
configuration
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Creating a new React Native Project
Creating a new project
react-native init MyProjectName
or
create-react-native-app MyProjectName
cd MyProjectName
react-native run-ios / run-android
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Main Ideas Behind React
Components, Rendering & Lifecycles
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
1. Stateless (function)
2. Stateful (class)
• Return a node
• Represent a piece of UI
• Can be created in one of two ways:
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Stateless Components
• Don’t need state or lifecycle methods
• Any update in the props will trigger a rerender
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Stateless Components
const MyComponent = () => (
<Text>Hello World</Text>
)
<MyComponent />
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Class / Stateful Components
class MyComponent extends React.Component {
render() {
return (
<Text>Hello World</Text>
)
}
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
3 types of component lifecycles
Creation / Mounting
Updating
Unmounting
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Creation / Mounting
constructor
static getDerivedStateFromProps(nextProps, prevState)
render
componentDidMount
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Updating
static getDerivedStateFromProps(nextProps, prevState)
shouldComponentUpdate(nextProps, nextState)
render
getSnapshotBeforeUpdate(prevProps, prevState)
componentDidUpdate
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Unmounting
componentWillUnmount
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Components
Lifecycle
class MyComponent extends React.Component {
constructor() { // 1
super()
this.name = 'My Cool Component’
}
static getDerivedStateFromProps(nextProps, prevState) {} // 2
componentDidMount() {} // 4
render() { // 3
return (
<Text>Hello World</Text>
)
}
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Data
State
class MyComponent extends React.Component {
state = { name: 'Nader’ }
changeName = () => {
this.setState({ name: 'Dennis' })
}
render() {
return (
<Text>Hello {this.state.name}</Text>
)
}
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Data
Props
class MyComponent extends React.Component {
render() {
return (
<Text>Hello {this.props.name}</Text>
)
}
}
<MyComponent name=‘Nader’ />
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you
Introduction to React Native
aws.amazon.com/mobile
@AWSforMobile

More Related Content

What's hot

An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Previewvaluebound
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page ApplicationKMS Technology
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React NativeFITC
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack IntroductionAnjali Chawla
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slidesmattysmith
 

What's hot (20)

An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
React js
React jsReact js
React js
 
React Native Workshop
React Native WorkshopReact Native Workshop
React Native Workshop
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page Application
 
React Native
React NativeReact Native
React Native
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Spring boot
Spring bootSpring boot
Spring boot
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 

Similar to Introduction to React Native

Introduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitIntroduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitAmazon Web Services
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesAmazon Web Services
 
Amazon CI-CD Practices for Software Development Teams
Amazon CI-CD Practices for Software Development Teams Amazon CI-CD Practices for Software Development Teams
Amazon CI-CD Practices for Software Development Teams Amazon Web Services
 
CI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateCI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateAmazon Web Services
 
Developing Serverless Application on AWS
Developing Serverless Application on AWSDeveloping Serverless Application on AWS
Developing Serverless Application on AWSAmazon Web Services
 
Serverless best practices plus design principles 20m version
Serverless   best practices plus design principles 20m versionServerless   best practices plus design principles 20m version
Serverless best practices plus design principles 20m versionHeitor Lessa
 
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...Amazon Web Services
 
From Code to a Running Container | AWS Floor28
From Code to a Running Container | AWS Floor28From Code to a Running Container | AWS Floor28
From Code to a Running Container | AWS Floor28Amazon Web Services
 
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Amazon Web Services
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon Web Services
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon Web Services
 
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer ToolsA Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer ToolsAmazon Web Services
 
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_Singapore
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_SingaporeCI-CD with AWS Developer Tools and Fargate_AWSPSSummit_Singapore
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_SingaporeAmazon Web Services
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon Web Services
 
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018Bhuvaneswari Subramani
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelAmazon Web Services
 
Building Microservices with the Twelve Factor App Pattern on AWS
Building Microservices with the Twelve Factor App Pattern on AWSBuilding Microservices with the Twelve Factor App Pattern on AWS
Building Microservices with the Twelve Factor App Pattern on AWSAmazon Web Services
 
How Zalando integrates Kubernetes with AWS
How Zalando integrates Kubernetes with AWSHow Zalando integrates Kubernetes with AWS
How Zalando integrates Kubernetes with AWSUri Savelchev
 

Similar to Introduction to React Native (20)

Introduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitIntroduction to React Native - Nader Dabit
Introduction to React Native - Nader Dabit
 
DevOps on AWS
DevOps on AWSDevOps on AWS
DevOps on AWS
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
 
Amazon CI-CD Practices for Software Development Teams
Amazon CI-CD Practices for Software Development Teams Amazon CI-CD Practices for Software Development Teams
Amazon CI-CD Practices for Software Development Teams
 
CI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateCI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and Fargate
 
Developing Serverless Application on AWS
Developing Serverless Application on AWSDeveloping Serverless Application on AWS
Developing Serverless Application on AWS
 
Serverless best practices plus design principles 20m version
Serverless   best practices plus design principles 20m versionServerless   best practices plus design principles 20m version
Serverless best practices plus design principles 20m version
 
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
 
From Code to a Running Container | AWS Floor28
From Code to a Running Container | AWS Floor28From Code to a Running Container | AWS Floor28
From Code to a Running Container | AWS Floor28
 
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Anaheim AWS ...
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Atlanta AWS ...
 
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer ToolsA Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
 
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_Singapore
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_SingaporeCI-CD with AWS Developer Tools and Fargate_AWSPSSummit_Singapore
CI-CD with AWS Developer Tools and Fargate_AWSPSSummit_Singapore
 
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
Amazon CI/CD Practices for Software Development Teams - SRV320 - Chicago AWS ...
 
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day Israel
 
Building Microservices with the Twelve Factor App Pattern on AWS
Building Microservices with the Twelve Factor App Pattern on AWSBuilding Microservices with the Twelve Factor App Pattern on AWS
Building Microservices with the Twelve Factor App Pattern on AWS
 
CI/CD@Scale
CI/CD@ScaleCI/CD@Scale
CI/CD@Scale
 
How Zalando integrates Kubernetes with AWS
How Zalando integrates Kubernetes with AWSHow Zalando integrates Kubernetes with AWS
How Zalando integrates Kubernetes with AWS
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Introduction to React Native

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Introduction to React Native Nader Dabit Developer Advocate, AWS Mobile Pop-up Loft
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Prerequisites • JavaScript, preferably ES6 / ES2015 • Knowledge of how to use the command line • Basic understanding of npm & how it works
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Environment • Node – version >= 4 • Watchman (if using React Native CLI) • Xcode (to run iOS simulator) • Genymotion or Android Studio (to run on Android Emulator)
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is React Native? • Built using React • Build cross platform applications using JavaScript • Target not only iOS & Android, but also Apple TV, VR, AR, Windows, & Desktop • Released March 2015 • Rapidly gaining in popularity & adoption • Learn once write anywhere • Real world projects typically see 80% – 95% code reuse
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Who’s using React Native • Facebook • Instagram • Walmart • Airbnb • Skype • Baidu • Tesla • Adidas • Discord • Wix • Bloomberg • JD.com
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Why React Native • Faster speed of development • Lower cost of development • Code reuse • Easier to find developers • Ship across multiple platforms • Possible to ship over the air updates bypassing App Store / Play Store
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does React Native Work? • JavaScript is bundled & minified using Babel (built in) • Separate threads for UI, layout, and JavaScript • Threads communicate asynchronously through the native bridge
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does React Native Work?
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native API View Text ScrollView Image TextInput Switch Over 30 UI Primitives
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native API View == div Text == span / p / h* ScrollView == div + styling Image == img TextInput == input Mapping to Web UI primitives
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native API import { View Text ScrollView Image TextInput Switch } from ‘react-native’ Primitives not globally in scope, must be imported
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native API CameraRoll Keyboard NetInfo Vibration PanResponder Device APIs
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native vs Web • Different primitives • Styling • Most browser APIs do not exist • Some browser APIs polyfilled (geolocation, fetch, timers, console) • Navigation • Mobile UI / UX • Native IDEs / configuration • Deployment
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native vs Web • Unlike web, not every component has every interaction • Handful of “touchable” components • Button, TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback • Create custom touchable components with PanResponder API Event handling
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native vs Web • Based on CSS styles • Layout is done with FlexBox • Style prop can be one or an array of styles • Use StyleSheet API for perf optimization • Makes it possible to refer to styles by ID instead of creating a new style object every time. • Allows to send the style only once through the bridge. All subsequent uses are going to refer an id (not implemented yet). Styling
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native vs Web JS Objects or inline styles Styling const styles = { container: { margin: 20, backgroundColor: ‘red’ } } <View style={styles.container} />
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. React Native vs Web Styling - StyleSheet import { StyleSheet } from ‘react-native’ const styles = StyleSheet.create({ container: { margin: 20, backgroundColor: ‘red’ } }) <View style={styles.container} />
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Creating a new React Native Project 2 Main Options React Native CLI Create React Native App CLI
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Creating a new React Native Project Create React Native App CLI • Builds without native projects & code • Native code not configurable • Will run without all SDKs & IDEs installed • Great for newer developers • Includes features like Camera, Location, Push Notifications, Social Authentication, Accelerometer, File System, & Image Picker configured out of the box
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Creating a new React Native Project React Native CLI • Builds with native projects & code • Native code configurable • Needs proper environment setup in order to run • Does not include some important APIs without additional configuration
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Creating a new React Native Project Creating a new project react-native init MyProjectName or create-react-native-app MyProjectName cd MyProjectName react-native run-ios / run-android
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Main Ideas Behind React Components, Rendering & Lifecycles
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components 1. Stateless (function) 2. Stateful (class) • Return a node • Represent a piece of UI • Can be created in one of two ways:
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Stateless Components • Don’t need state or lifecycle methods • Any update in the props will trigger a rerender
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Stateless Components const MyComponent = () => ( <Text>Hello World</Text> ) <MyComponent />
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Class / Stateful Components class MyComponent extends React.Component { render() { return ( <Text>Hello World</Text> ) } }
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components 3 types of component lifecycles Creation / Mounting Updating Unmounting
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Creation / Mounting constructor static getDerivedStateFromProps(nextProps, prevState) render componentDidMount
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Updating static getDerivedStateFromProps(nextProps, prevState) shouldComponentUpdate(nextProps, nextState) render getSnapshotBeforeUpdate(prevProps, prevState) componentDidUpdate
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Unmounting componentWillUnmount
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Components Lifecycle class MyComponent extends React.Component { constructor() { // 1 super() this.name = 'My Cool Component’ } static getDerivedStateFromProps(nextProps, prevState) {} // 2 componentDidMount() {} // 4 render() { // 3 return ( <Text>Hello World</Text> ) } }
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Data State class MyComponent extends React.Component { state = { name: 'Nader’ } changeName = () => { this.setState({ name: 'Dennis' }) } render() { return ( <Text>Hello {this.state.name}</Text> ) } }
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Data Props class MyComponent extends React.Component { render() { return ( <Text>Hello {this.props.name}</Text> ) } } <MyComponent name=‘Nader’ />
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you Introduction to React Native aws.amazon.com/mobile @AWSforMobile