Upgrade to Pro — share decks privately, control downloads, hide ads and more …

React Native

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

React Native

Avatar for Sing Jie Lee

Sing Jie Lee

April 22, 2016
Tweet

More Decks by Sing Jie Lee

Other Decks in Technology

Transcript

  1. – https://facebook.github.io/react-native/ “The focus of React Native is on developer

    efficiency across all the platforms you care about — learn once, write anywhere.”
  2. PROBLEMS WITH NATIVE • Slow development cycle • Slow deployment

    cycle • Different API for same thing • Separate platform teams
  3. REACT NATIVE • Slow development cycle • Slow deployment cycle

    • Different API for same thing • Separate platform teams • Instant Reload • OTA Updates • Common APIs • Shared Skill set
  4. ADVANTAGES • CMD+R • Javascript! Learn once, write anywhere •

    Functional UI • Flexbox layout • Highly extensible
  5. JAVASCRIPT import React, { AppRegistry, Component, StyleSheet, Text, View }

    from 'react-native'; class EmmaLee extends Component { render() { return ( React.createElement(Text, {style: styles.welcome}, “Welcome to React Native!”) ); } } var styles = StyleSheet.create({ welcome: { fontSize: 30,textAlign: ‘center’ }
 }); AppRegistry.registerComponent('EmmaLee', () => EmmaLee);
  6. JSX import React, { AppRegistry, Component, StyleSheet, Text, View }

    from 'react-native'; class EmmaLee extends Component { render() { return ( <Text style={styles.welcome}> Welcome to React Native! </Text> ); } } var styles = StyleSheet.create({ welcome: { fontSize: 30,textAlign: ‘center’ }
 }); AppRegistry.registerComponent('EmmaLee', () => EmmaLee);
  7. FUNCTIONAL UI import React, { AppRegistry, Component, StyleSheet, Text, View

    } from 'react-native'; class EmmaLee extends Component { render() { return ( <Text style={styles.welcome}> Welcome to React Native! </Text> ); } } var styles = StyleSheet.create({ welcome: { fontSize: 30,textAlign: ‘center’ }
 }); AppRegistry.registerComponent('EmmaLee', () => EmmaLee);
  8. FUNCTIONAL UI this.state this.state.text2 this.state.text1 render() { return ( <View

    style={styles.container}> <Text style={styles.text}>{this.state.text1}</Text> <Image style={styles.image} source={{uri: "some_url"}}/> <Text style={styles.text}>{this.state.text2}</Text> </View> ); }
  9. NATIVE UI COMPONENTS // RCTMapManager.m #import <MapKit/MapKit.h> #import "RCTViewManager.h" @interface

    RCTMapManager : RCTViewManager @end @implementation RCTMapManager RCT_EXPORT_MODULE() - (UIView *)view { return [[MKMapView alloc] init]; } @end import { requireNativeComponent } from 'react-native'; module.exports = requireNativeComponent('RCTMap', null); Objective-C Javascript
  10. NATIVE MODULES // CalendarManager.h #import "RCTBridgeModule.h" @interface CalendarManager : NSObject

    <RCTBridgeModule> @end // CalendarManager.m @implementation CalendarManager RCT_EXPORT_MODULE(); RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location) { NSLog(@"Pretending to create an event %@ at %@", name, location); } @end import { NativeModules } from 'react-native'; var CalendarManager = NativeModules.CalendarManager; CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey'); Objective-C Javascript