This document introduces React Native, which allows developers to build native mobile apps for iOS and Android from JavaScript. React Native uses React to construct mobile user interfaces and allows sharing of code across platforms. It renders native UI components rather than webviews, supports flexbox layout, and exposes platform APIs. Developers can build full-stack universal apps that share code between web and mobile using React Native and tools like Redux. It provides benefits like hot reloading, native performance, and the ability to add it incrementally to existing apps.
3. FRONT-END IS BROKEN
• Build the same app 3-6 times: iOS (Phone/Tablet),
Android (Phone/Tablet), Web (Desktop/Phone)
• Different teams build the same thing using 3
different languages, frameworks & libraries.
• Hard to maintain feature parity & consistent
terminology.
• Impossible to be an expert in all technologies and
“own” something in all products
5. BUSINESS-CENTRIC R&D
Feature A
Product Manager
Feature B Feature C
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
Full-Stack Dev
6. FULL-STACK IS HARD!
• Almost all devs at Wondermall do Python, ObjC+Swift
and AngularJS
• Level of expertise vary. No one is a rock star on all 3
platforms
• We’ll never get everyone cross trained on Android,
Windows Phone, Apple Watch, Apple TV, …
• If we want to remain Full Stack, we’ll have to rethink our
strategy
11. HELLO WORLD
var React = require('react')
var { View, Text } = require('react-native')
class HelloWorldView extends React.Component {
render() {
return (
<View><Text>Hello World</Text></View>
)
}
}
12. React DOM React Native
React
React Canvas React Three
iOS Android macOS Win 10 Web
REACT ECO-SYSTEM
Tizen
13. REACT (NATIVE+JS)
BENEFITS
• “Learn once write anywhere”
• Reuse almost all non-UI code across all
platforms
• Reuse most UI code between Native
Platforms
• Hot-reloading JS, debug in Chrome
14. BENEFITS - CON’T
• Can be added incrementally to an existing
app
• Over-the-wire updates w/o AppStore
(AppHub)
• JS w/ ES6 is succinct and productive
• Can use previously written native code and
UI
24. Shared - Native & Web
Redux /
Relay
API Client
Business
Logic
Shared Native
Native Specific
<TabBarIOS>,
<AndroidToolbar>
<Text>, <TextInput>,
<Image>
Web
<div>
Business Level Comp’
<span>
<img>
26. • Reload - Clears all JS code and resets
the state
• Remote JS Debugging - Chrome /
VSCode with breakpoints and Console
(no network)
• Live Reload - Automatic Reload (as
above)
• Hot Reloading - Change JS code without
DEVELOPER MENU
28. PACKAGER
• Built-in packager with ES6 support
• Development: local webserver serves the
bundled JS
• Production:
• Use .ios.js or .android.js suffixes, Packager will
include the correct file for the platform bundle
$ react-native bundle —platform ios
29. OTA UPDATES
• Updates JS & assets without AppStore submission
• Apple’s policy allows it for fixes & minor
improvements
• Microsoft CodePush - Commercial
• AppHub - Hosted / OSS
Agenda:
Motivation
Basics
Eco-System + Benefits
Styling, Layout & Routing
Universal Apps
Debugging & Tooling
Internals
Misc
Who has Redux exp.? Who has R/N exp.?
React Native appears to both JS (“Web”) developers & Native developers
Runs on a separate thread, doesn’t block UI, talks to Native via a bridge. Reuse the enormous JS ecosystem.
Wrapped by JS and touched only by the framework
Fast (transpiled to C and Java), Flexible, much easier than AutoLayout
Generates standard iOS and Android projects that create a normal binary distribution
ES6 destructors + Class syntax (mention constructor, super)
JSX
Same techniques, libraries, mental models. Become an “Uberstack Developer”
Web has different form factor so re-build the UI anyway. iOS and Android have diff standard components.
FB Ads Manager (iOS & Android) reused 90% for Android
Great way to give it a try w/o betting the company
Has great implications on testing strategy, fast response to bugs.
Lambdas, Class syntax
Can bring pure-native components if RN is lacking or want to leverage previous investments.
Flex value > 0 means “fill in the parent”. Then, flex divides the space relative to the value.
Integrates tab and navigation stack (back button)
API Client - fetch polypill
For web - consider React-Native-Web
Production: JS packaged into the binary distribution
Crashlytics Integration
RCTRootView is a subclass of UIView
It can be the only thing in your app or just another “screen”
You can have several such views sharing a bridge
Share the context, e.g. Redux state
Use AppRegistry.registerComponent for each root component that RCTRoowViewLoads