SlideShare a Scribd company logo
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
React native: building shared components for Android and iOS
React native: building shared components for Android and iOS
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
React native: building shared components for Android and iOS
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)
}
React native: building shared components for Android and iOS
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

More Related Content

PPTX
Angular 2 with TypeScript
PDF
Building End-to-End Apps Using Typescript
PDF
Automated Testing with GHUnit and KIF
PDF
Angular.js for beginners
PDF
Stock Price Predictor - Python with AI Student Project
PDF
Basic overview of Angular
PPT
JAX 08 - Agile RCP
PPT
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
Angular 2 with TypeScript
Building End-to-End Apps Using Typescript
Automated Testing with GHUnit and KIF
Angular.js for beginners
Stock Price Predictor - Python with AI Student Project
Basic overview of Angular
JAX 08 - Agile RCP
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...

Similar to React native: building shared components for Android and iOS (20)

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

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
KodekX | Application Modernization Development
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
MIND Revenue Release Quarter 2 2025 Press Release
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The Rise and Fall of 3GPP – Time for a Sabbatical?
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
KodekX | Application Modernization Development
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
Advanced methodologies resolving dimensionality complications for autism neur...
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Ad

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
  • 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
  • 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) }
  • 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

Editor's Notes

  • #2: Intro - who am I, what do I do?
  • #3: React = a js library for building user interfaces: component based, React - 2013 RN - 2015
  • #4: Write Once, run anywhere - Sun microsystems 1996 on Java Previous attempts at x platform development have mostly been webviews
  • #5: Predominantly renders into a webview (with the exception of Xamarin)
  • #6: Establish definition of brownfield vs greenfield Greenfield apps - Uber Eats Instagram + Airbnb
  • #7: If you have interacted with these screens then you have used React Native After this we were curious to understand the technology
  • #8: 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 :(
  • #10: Taking a skeptical approach
  • #11: 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
  • #13: JSX is a preprocessor step that adds XML syntax to JavaScript.
  • #15: The props is the agentId We want our native apps to render this
  • #16: Agent React Activity - extends ReactActivity
  • #17: AgentViewController.swift
  • #18: Different styles?
  • #19: Platform specific styling
  • #20: 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
  • #21: 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
  • #22: 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
  • #23: Single NPM module Centralised repo - minimal JS in the native codebases In the package.json Native PR is only a version number increase
  • #24: Separate Demo App - allows React developers to work away from the Native codebases Debugging is possible here Hot reloading + live reload - no recompiling here
  • #25: 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
  • #26: 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).