Slide 1

Slide 1 text

Cross-Platform React Native What does that really mean? Connor McEwen

Slide 2

Slide 2 text

About Me cmcewen @connormcewen Lead Engineer, Emerging Products Using React Native since the beta

Slide 3

Slide 3 text

Flare • Small business community app • 100% React Native • Featured in App Store + Google Play Store

Slide 4

Slide 4 text

RN Cross-Platform …We’re not chasing “write once, run anywhere.” We call this approach “learn once, write anywhere.” iOS

Slide 5

Slide 5 text

How it works http://tadeuzagallo.com/blog/react-native-bridge/ iOS … Same API

Slide 6

Slide 6 text

How it works class Hello extends React.Component { render() { return( Hello world! ) } } - (UIView *)view { return [RCTView new]; } @Override public ReactViewGroup createViewInstance(Them return new ReactViewGroup(context); }

Slide 7

Slide 7 text

The Dream

Slide 8

Slide 8 text

Reality

Slide 9

Slide 9 text

Why? • Design choices - material design • Phone features - hardware back button • Different APIs - permissions • Performance • Layout

Slide 10

Slide 10 text

How • .ios.js + .android.js • inline Platform.OS class Hello extends Component { render() { return( I’m iOS! ) } } class Hello extends Component { render() { return( I’m Android! ) } } class Hello extends Component { render() { if (Platform.OS === ‘ios’) { return( I’m iOS! ) } else { return( I’m Android! ) } } }

Slide 11

Slide 11 text

Our stats • 166 total files in js directory • 4 .android.js + 4.ios.js = 4.8% • 37 .js use the Platform API = 22% imageContainer: { paddingTop: Platform.OS === 'ios' ? 5 : 10 },

Slide 12

Slide 12 text

Timeline Started working on Flare on iOS Aug. 2015 RN Android released Sep. 2015 Initial Flare Android version Mar. 2016 iOS release + feature May 2016 Oh shit Android bugs + perf June 2016 Android release June 2016 Google feedback to get featured July 2016 Android feature Aug 2016

Slide 13

Slide 13 text

Key differences • Material Design • Touchables • Permissions APIs

Slide 14

Slide 14 text

Lesson Learned • Test both platforms early • Don’t use negative absolute positions • You might need to make native modules for parity • Things have gotten much better

Slide 15

Slide 15 text

Thanks! @connormcewen