Slide 1

Slide 1 text

React Native @ Airbnb FELIPE LIMA & LELAND RICHARDSON

Slide 2

Slide 2 text

Why React Native?

Slide 3

Slide 3 text

We build Airbnb 3 times

Slide 4

Slide 4 text

We build Airbnb 3 times

Slide 5

Slide 5 text

JavaScript Core VM Native UI Platform

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Developer Experience

Slide 8

Slide 8 text

User Experience Developer Experience

Slide 9

Slide 9 text

User Experience Developer Experience Web Native Mobile React Native Developer Experience User Experience Web Native RN

Slide 10

Slide 10 text

Live Reload

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Code Push

Slide 13

Slide 13 text

Code Push - OTA updates - Hot Fixes - Experimentation - Continuous Deployment

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Type Safety

Slide 16

Slide 16 text

Performance

Slide 17

Slide 17 text

Misconceptions

Slide 18

Slide 18 text

Does the JS compile to native code? No.

Slide 19

Slide 19 text

Does the JS runs in a web view? No.

Slide 20

Slide 20 text

What if I want to use the platform’s latest API’s? Use them!

Slide 21

Slide 21 text

How does it work?

Slide 22

Slide 22 text

Bridge JavaScript Core VM Native UI Platform Layout Rendering Gestures Application Logic UI Description

Slide 23

Slide 23 text

Shadow JSC Main Gesture / Interaction

Slide 24

Slide 24 text

Shadow JSC Main Gesture / Interaction React Render

Slide 25

Slide 25 text

Shadow JSC Main Gesture / Interaction React Render Diff

Slide 26

Slide 26 text

Shadow JSC Main Gesture / Interaction React Render Layout Diff

Slide 27

Slide 27 text

Shadow JSC Main Gesture / Interaction React Render Layout Render Diff

Slide 28

Slide 28 text

Shadow JSC Main Gesture / Interaction React Render Layout Render Diff 16 ms

Slide 29

Slide 29 text

React

Slide 30

Slide 30 text

UI = f(state)

Slide 31

Slide 31 text

import React from 'react'; class HelloWorld extends React.Component { render() { return (
Hello World
); } }

Slide 32

Slide 32 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloWorld extends React.Component { render() { return ( Hello World ); } }

Slide 33

Slide 33 text

import { View, Text, Image, ScrollView, TextInput, ListView, MapView, ... } from 'react-native';

Slide 34

Slide 34 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloWorld extends React.Component { render() { return ( Hello World ); } }

Slide 35

Slide 35 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloWorld extends React.Component { render() { return { type: View, props: null, children: [{ type: Text, props: null, children: ['Hello World'], }], }; } }

Slide 36

Slide 36 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloWorld extends React.Component { render() { return ( Hello World ); } }

Slide 37

Slide 37 text

import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; class HelloWorld extends React.Component { render() { return ( Hello World ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, message: { fontSize: 28, fontColor: '#222222', }, });

Slide 38

Slide 38 text

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, message: { fontSize: 28, fontColor: '#222222', }, }); { container: { top: 0, left: 0, width: 370, height: 600, }, message: { top: 280, left: 125, width: 120, height: 40, }, }

Slide 39

Slide 39 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloWorld extends React.Component { render() { return ( Hello World ); } }

Slide 40

Slide 40 text

import React from 'react'; import { View, Text } from 'react-native'; class HelloUser extends React.Component { render() { return ( Hello, {this.props.name} ); } }

Slide 41

Slide 41 text

import React from 'react'; import { View } from 'react-native'; import HelloUser from './HelloUser'; class HelloApp extends React.Component { render() { const { user } = this.props; return ( ); } }

Slide 42

Slide 42 text

Native Modules

Slide 43

Slide 43 text

class AccountModule extends ReactContextBaseJavaModule {
 AccountModule(ReactApplicationContext reactContext) {
 super(reactContext);
 }
 
 @Override
 public String getName() {
 return "AccountBridge";
 }
 
 @Override
 public Map getConstants() {
 return Collections.emptyMap();
 } @ReactMethod
 public void setUserLocation(String location) {
 currentUser.setLocation(location);
 }
 
 @Subscribe
 public void loginStatusChanged(AuthStateEvent lse) {
 ReactApplicationContext context = getReactApplicationContext();
 context.getJSModule(RCTDeviceEventEmitter.class)
 .emit("airbnb.accountUpdated", toWritableMap(getData()));
 }
 }

Slide 44

Slide 44 text

class ReactAirImageManager extends SimpleViewManager {
 @Override
 public String getName() {
 return "RCTImageView";
 }
 
 @Override
 protected ReactAirImageView createViewInstance(ThemedReactContext context) {
 return new ReactAirImageView(context, null);
 }
 
 @ReactProp(name = "src")
 public void setSource(ReactAirImageView view, @Nullable ReadableArray sources) {
 view.setSource(sources);
 }
 
 @ReactProp(name = "borderColor", defaultInt = Color.TRANSPARENT, customType = "Color")
 public void setBorderColor(ReactAirImageView view, int borderColor) {
 view.setBorderColor(Color.RED);
 } }

Slide 45

Slide 45 text

I’ll believe it when I see it…

Slide 46

Slide 46 text

Thank You Leland Richardson @intelligibabble Felipe Lima @felipecsl

Slide 47

Slide 47 text

No content