SlideShare une entreprise Scribd logo
1  sur  27
React Native: Building
Shared Components for
Android and iOS
Calum Gathergood
https://www.linkedin.com/in/calumgathergood/@cgathergood
React Native
Learn once, write anywhere: Build mobile apps
with React
https://facebook.github.io/react-native/
Learn once, write anywhere
Sound familiar?
Write once debug everywhere
StackOverflow Official Developer
Survey 2017
https://insights.stackoverflow.com/survey/2017
72% of respondents labelled themselves as
Web Developers (23% mobile developers)
Javascript is the most popular language for
the 5th year in a row
React is the most loved technology of 2017
Calum’s Unofficial Domain Developer
Survey 2017
5 Android Developers
8 iOS Developers
30 React Developers
Motivations
Don’t trust the sales pitch
Understand the technology
Validate how useful RN can be with our ‘brownfield’
apps
Agent Profiles
Basic Component import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
export default class MyComponent extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.paragraph}>
Hello Android Meetup!
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
paragraph: {
fontSize: 18,
textAlign: 'center',
color: '#34495e',
},
});
Props
// Main Component
<WelcomeComponent name='Calum' />
// Welcome Component (inside render method)
<Text>Welcome {this.props.name}</Text>
<AgentProfile agentId={1234} />
@Override
protected String getMainComponentName() {
return "AgentProfile";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName())
{
@Nullable @Override
protected Bundle getLaunchOptions() {
Bundle initialProps = new Bundle();
initialProps.putString("agentId",
getIntent().getStringExtra(EXTRA_AGENT_PROFILE_ID));
return initialProps;
}
};
}
private let props: [String: String]
private lazy var rootView: RCTRootView = {
let releaselocation = RCTBundleURLProvider.sharedSettings().jsBundleURL()
return RCTRootView(bundleURL: releaselocation, moduleName: "AgentProfile",
initialProperties: self.props, launchOptions: nil)
}()
init(agencyId: Int) {
var buildProps: [String: String] = [:]
buildProps["agentId"] = String(describing: agencyId)
self.props = buildProps
super.init(nibName: nil, bundle: nil)
}
enquiryInput: {
fontSize: 18,
marginTop: 20,
color: '#000',
fontFamily: typography.FONT.REGULAR,
...Platform.select({
ios: {
borderRadius: 2,
borderWidth: 1,
borderColor: '#A9AFBA',
},
android: {
marginTop: 18,
},
}),
},
Styling Components
How do we track stats and report
errors?
@ReactMethod
public void trackEvent(String category, final
String action) {
trackingManager.event(category, action);
}
trackEvent(categoryName, eventName) {
TrackingModule.trackEvent(categoryName,
eventName);
}
@objc(trackEvent:eventName:)
public func trackEvent(category: String, eventName: String) {
TrackingController.trackEvent(category, eventName: eventName)
}
Native Bridging
Implementing tracking events
natively:
- Create a native tracking module
- Define methods (match name
with JS)
- Use parameters with existing
tracking managers
Caveats
Debugging
Performance Issues
Learning Curve for initial setup/configuration
Managing multiple components in
a monorepo
"dependencies": {
"react-native-monorepo": "1.2.3",
...
}
Monorepo
Separate development environment
Debugging works
Demo App Available
Our Conclusion
Low barrier for entry (we have heaps of React devs)
Better than a webview - “I can’t believe it’s not Native”
You don’t have to commit to using React Native
Developer Velocity - Write once run everywhere...
Future of RN - React as a platform
React Primitives - Web + Mobile + VR
Codepush
Further development of native components
React Native: Bringing modern web techniques to mobile (Facebook)
Powering UberEats with React Native and Uber Engineering
Leland Richardson - React Native in the "Brown Field" - React Conf 2017
How Airbnb Is Using React Native
React Native at Instagram
create-react-native-app
Try it out now - https://expo.io/
Useful Resources
Thanks!
https://www.linkedin.com/in/calumgathergood/@cgathergood

Contenu connexe

Similaire à React native: building shared components for Android and iOS

React Native custom components
React Native custom componentsReact Native custom components
React Native custom componentsJeremy Grancher
 
CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19Gobinath Subramaniam
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Matteo Collina
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
7 Ways to improve your gradle build
7 Ways to improve your gradle build7 Ways to improve your gradle build
7 Ways to improve your gradle buildTania Pinheiro
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Ontico
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android projectVitali Pekelis
 
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfTK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfLam Chun
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveVin Lim
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)Bramus Van Damme
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android ProgrammingRaveendra R
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material DesignYasin Yildirim
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Nicolas HAAN
 
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
 
Create Modern Apps with Android Jetpack
Create Modern Apps with Android JetpackCreate Modern Apps with Android Jetpack
Create Modern Apps with Android JetpackRamon Ribeiro Rabello
 
My Story & Features from .NET Core 3.0
My Story & Features from .NET Core 3.0My Story & Features from .NET Core 3.0
My Story & Features from .NET Core 3.0Vladimir Georgiev
 

Similaire à React native: building shared components for Android and iOS (20)

React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 
CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19CS6611 Mobile Application Development Lab Manual-2018-19
CS6611 Mobile Application Development Lab Manual-2018-19
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
7 Ways to improve your gradle build
7 Ways to improve your gradle build7 Ways to improve your gradle build
7 Ways to improve your gradle build
 
Android Made Simple
Android Made SimpleAndroid Made Simple
Android Made Simple
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfTK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
 
Go react codelab
Go react codelabGo react codelab
Go react codelab
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material Design
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
 
React Native
React NativeReact Native
React Native
 
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
 
Create Modern Apps with Android Jetpack
Create Modern Apps with Android JetpackCreate Modern Apps with Android Jetpack
Create Modern Apps with Android Jetpack
 
My Story & Features from .NET Core 3.0
My Story & Features from .NET Core 3.0My Story & Features from .NET Core 3.0
My Story & Features from .NET Core 3.0
 

Dernier

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

React native: building shared components for Android and iOS

  • 1. React Native: Building Shared Components for Android and iOS Calum Gathergood https://www.linkedin.com/in/calumgathergood/@cgathergood
  • 2. React Native Learn once, write anywhere: Build mobile apps with React https://facebook.github.io/react-native/
  • 3. Learn once, write anywhere Sound familiar?
  • 4. Write once debug everywhere
  • 5.
  • 6.
  • 7. StackOverflow Official Developer Survey 2017 https://insights.stackoverflow.com/survey/2017 72% of respondents labelled themselves as Web Developers (23% mobile developers) Javascript is the most popular language for the 5th year in a row React is the most loved technology of 2017
  • 8. Calum’s Unofficial Domain Developer Survey 2017 5 Android Developers 8 iOS Developers 30 React Developers
  • 9. Motivations Don’t trust the sales pitch Understand the technology Validate how useful RN can be with our ‘brownfield’ apps
  • 11.
  • 12. Basic Component import React, { Component } from 'react'; import { Text, View, StyleSheet } from 'react-native'; export default class MyComponent extends Component { render() { return ( <View style={styles.container}> <Text style={styles.paragraph}> Hello Android Meetup! </Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', }, paragraph: { fontSize: 18, textAlign: 'center', color: '#34495e', }, });
  • 13. Props // Main Component <WelcomeComponent name='Calum' /> // Welcome Component (inside render method) <Text>Welcome {this.props.name}</Text>
  • 15. @Override protected String getMainComponentName() { return "AgentProfile"; } @Override protected ReactActivityDelegate createReactActivityDelegate() { return new ReactActivityDelegate(this, getMainComponentName()) { @Nullable @Override protected Bundle getLaunchOptions() { Bundle initialProps = new Bundle(); initialProps.putString("agentId", getIntent().getStringExtra(EXTRA_AGENT_PROFILE_ID)); return initialProps; } }; }
  • 16. private let props: [String: String] private lazy var rootView: RCTRootView = { let releaselocation = RCTBundleURLProvider.sharedSettings().jsBundleURL() return RCTRootView(bundleURL: releaselocation, moduleName: "AgentProfile", initialProperties: self.props, launchOptions: nil) }() init(agencyId: Int) { var buildProps: [String: String] = [:] buildProps["agentId"] = String(describing: agencyId) self.props = buildProps super.init(nibName: nil, bundle: nil) }
  • 17.
  • 18. enquiryInput: { fontSize: 18, marginTop: 20, color: '#000', fontFamily: typography.FONT.REGULAR, ...Platform.select({ ios: { borderRadius: 2, borderWidth: 1, borderColor: '#A9AFBA', }, android: { marginTop: 18, }, }), }, Styling Components
  • 19. How do we track stats and report errors?
  • 20. @ReactMethod public void trackEvent(String category, final String action) { trackingManager.event(category, action); } trackEvent(categoryName, eventName) { TrackingModule.trackEvent(categoryName, eventName); } @objc(trackEvent:eventName:) public func trackEvent(category: String, eventName: String) { TrackingController.trackEvent(category, eventName: eventName) } Native Bridging Implementing tracking events natively: - Create a native tracking module - Define methods (match name with JS) - Use parameters with existing tracking managers
  • 21. Caveats Debugging Performance Issues Learning Curve for initial setup/configuration
  • 22. Managing multiple components in a monorepo "dependencies": { "react-native-monorepo": "1.2.3", ... }
  • 24. Our Conclusion Low barrier for entry (we have heaps of React devs) Better than a webview - “I can’t believe it’s not Native” You don’t have to commit to using React Native Developer Velocity - Write once run everywhere...
  • 25. Future of RN - React as a platform React Primitives - Web + Mobile + VR Codepush Further development of native components
  • 26. React Native: Bringing modern web techniques to mobile (Facebook) Powering UberEats with React Native and Uber Engineering Leland Richardson - React Native in the "Brown Field" - React Conf 2017 How Airbnb Is Using React Native React Native at Instagram create-react-native-app Try it out now - https://expo.io/ Useful Resources

Notes de l'éditeur

  1. Intro - who am I, what do I do?
  2. React = a js library for building user interfaces: component based, React - 2013 RN - 2015
  3. Write Once, run anywhere - Sun microsystems 1996 on Java Previous attempts at x platform development have mostly been webviews
  4. Predominantly renders into a webview (with the exception of Xamarin)
  5. Establish definition of brownfield vs greenfield Greenfield apps - Uber Eats Instagram + Airbnb
  6. If you have interacted with these screens then you have used React Native After this we were curious to understand the technology
  7. Over 64,000 respondents Javascript’s 5th year in a row at number 1 (select all that apply) Java is high (3rd after SQL) Swift vs Obj C is pretty even No Kotlin :(
  8. Taking a skeptical approach
  9. Real estate Agents like to see their faces Single Page showing agent profile information Would have traditionally used a webview Good use case Relatively low traffic (we have existing stats on this) Images, text, lists of property listings Currently able to send enquiry or phone
  10. JSX is a preprocessor step that adds XML syntax to JavaScript.
  11. The props is the agentId We want our native apps to render this
  12. Agent React Activity - extends ReactActivity
  13. AgentViewController.swift
  14. Different styles?
  15. Platform specific styling
  16. Domain is data driven We want to maintain our google analytics session - don’t break the flow In order to do this we want the react component to communicate back to each native app
  17. Native Bridge (Tracking) Shows how to define ReactMethods - extends ReactContextBaseJavaModule Links in with existing tracking SafeModule App flow is uninterrupted (analytics) Also catches errors in Fabric
  18. Android Images use fresco under the hood Flatlist issues Native devs had to JS / JS devs had to learn native ecosystems to a minor degree
  19. Single NPM module Centralised repo - minimal JS in the native codebases In the package.json Native PR is only a version number increase
  20. Separate Demo App - allows React developers to work away from the Native codebases Debugging is possible here Hot reloading + live reload - no recompiling here
  21. Ultimately RN is rendered natively Good for atomic single uses i.e. low-traffic screen Don’t have to go all in! With our monorepo react devs can work on it without interfering with the native teams
  22. React Primitives - This library attempts to propose an ideal set of primitives around building React applications, regardless of Platform. Codepush - is a cloud service that enables Cordova and React Native developers to deploy mobile app updates directly to their users’ devices. It works by acting as a central repository that developers can publish certain updates to (e.g. JS, HTML, CSS and image changes), and that apps can query for updates from (using our provided client SDKs).