a tour of react native
TRANSCRIPT
WHAT IS REACT NATIVE?
React Native lets you build mobile apps using only JavaScript. It uses the same design as React, letting you compose a rich mobile UI from
declarative components.— facebook.github.io/react-native
@tadeuzagallo
if (count > 99) { // branch 1 if (!hasFire()) { // branch 2 addFire(); }} else { if (hasFire()) { // branch 3 removeFire(); }}if (count === 0) { // branch 4 if (hasBadge()) { // branch 5 removeBadge(); } return;}if (!hasBadge()) { // branch 6 addBadge();}var countText = count > 99 ? '99+' : count.toString(); // branch 7getBadge().setText(countText);
@tadeuzagallo
DECLARATIVE UI: DEFINE STATES
if (count === 0) { // state 1 return <Bell/>;} else if(count <= 99) { // state 2 return ( <Bell> <Badge count={count}/> </Bell> );}
@tadeuzagallo
DECLARATIVE UI: DEFINE STATES
if (count === 0) { // state 1 return <Bell/>;} else if(count <= 99) { // state 2 return ( <Bell> <Badge count={count}></Badge> </Bell> );} else { // state 3 return ( <Bell style={styles.onFire}> <Badge count="99+"/> </Bell> );}
@tadeuzagallo
WEB ➡ NATIVE
Open Standards ➡ Proprietary PlatformsInstant Distribution ➡ Distributing Binaries
Reload and Run ➡ Compile and Wait Product Teams ➡ Platform-aware Teams
@tadeuzagallo
➡ NATIVE ➡ REACT NATIVE
➡ Proprietary Platforms ➡ Open Source ➡ Distributing Binaries ➡ Instant Distribution➡ Compile and Wait ➡ Reload and Run ➡ Platform-aware Teams ➡ Unified Teams
@tadeuzagallo
➡ NATIVE ➡ REACT NATIVE
➡ Proprietary Platforms ➡ Open Source ➡ Distributing Binaries ➡ Instant Distribution➡ Compile and Wait ➡ Reload and Run ➡ Platform-aware Teams ➡ Unified Teams ➡ Imperative APIs ➡ Declarative APIs
@tadeuzagallo
import React, { Component,} from 'react';
import { AppRegistry, Text,} from 'react-native';
class SampleApp extends Component { render() { return ( <Text style={{ margin: 40 }}> Hello, World! </Text> ); }}
AppRegistry.registerComponent('SampleApp', () => SampleApp);
@tadeuzagallo
@implementation MyNativeModule
+ (NSString *)moduleName { return @""; }+ (void)load { RCTRegisterModule(self); }
@end
@tadeuzagallo
{ "remoteModuleConfig":[ // [ // $moduleName : string, // $exportedConstants? : { [key: string]: string }, // $methods? : [string], // $asyncIndexes? : [number] // ] ["RCTSourceCode",{"scriptURL":"http:\/\/localhost:8081\/index.ios.bundle?platform=ios&dev=true"},["getScriptText"],[0]], ["RCTStatusBarManager",["getHeight","setStyle","setHidden","setNetworkActivityIndicatorVisible"]], ["RCTAlertManager",["alertWithArgs"]], ["RCTExceptionsManager",["reportSoftException","reportFatalException","updateExceptionMessage","reportUnhandledException"]], // ... ]}
@tadeuzagallo
// import React, {// Component,// } from 'react';//// import {// AppRegistry,// Text, TouchableHighlight,// } from 'react-native';//// class SampleApp extends Component { onPress() { alert('Hello, World!'); }// render() {// return ( <TouchableHighlight style={{ margin: 40 }} onPress={this.onPress}> <Text> Button <⁄Text> </TouchableHighlight>;// );// }// }//// AppRegistry.registerComponent('SampleApp', () => SampleApp);
@tadeuzagallo
if (Platform.OS === 'ios') { AlertIOS.alert(title, message, buttons);} else if (Platform.OS === 'android') { AlertAndroid.alert(title, message, buttons);}
@tadeuzagallo