React Native Internals

45
REACT NATIVE Internals @tadeuzagallo #reactamsterdam

Transcript of React Native Internals

REACT NATIVEInternals

@tadeuzagallo #reactamsterdam

ABOUT Me

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

WHAT HAPPENS WHENYOU TYPE A URL INTO YOUR BROWSER

AND PRESS ENTER?

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

What HAPPENS WHEN YOU RUN A React Native APP?

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

▸ No WebView▸ No HTML▸ No CSS

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

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 #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@implementation MyNativeModule

RCT_EXPORT_MODULE()

@end

@tadeuzagallo #reactamsterdam

@implementation MyNativeModule

+ (NSString *)moduleName { return @""; }+ (void)load { RCTRegisterModule(self); }

@end

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

{ "remoteModuleConfig":[ // [ $moduleName, $exportedConstants:{}? $methods:[]?, $asyncIndexes:[]? ] ["RCTStatusBarManager",["getHeight","setStyle","setHidden","setNetworkActivityIndicatorVisible"]], ["RCTSourceCode",{"scriptURL":"http:\/\/localhost:8081\/index.ios.bundle?platform=ios&dev=true"},["getScriptText"],[0]], ["RCTAlertManager",["alertWithArgs"]], ["RCTExceptionsManager",["reportSoftException","reportFatalException","updateExceptionMessage","reportUnhandledException"]], // ... ]}

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

VMBasics

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

// 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 #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

class SampleApp extends Component { onPress() {-> alert('Hello, World!'); } ... }

@tadeuzagallo #reactamsterdam

if (Platform.OS === 'ios') { AlertIOS.alert(title, message, buttons);} else if (Platform.OS === 'android') { AlertAndroid.alert(title, message, buttons);}

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

// import React, {// Component,// } from 'react';//// import {// AppRegistry,// Text,// TouchableHighlight,// } from 'react-native';//// class SampleApp extends Component {// onPress() { Alert.alert('Hello, World!', 'Press ok to alert again', [ { text: 'Ok', onPress() { alert('Ok!') } }, { text: 'Cancel', onPress() { alert('Cancel') } }, ]);// }// render() {// return (// <TouchableHighlight style={{ margin: 40 }} onPress={this.onPress}>// <Text>// Button// </Text>// </TouchableHighlight>;// );// }// }//// AppRegistry.registerComponent('SampleApp', () => SampleApp);

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

@tadeuzagallo #reactamsterdam

Thank you

@tadeuzagallo #reactamsterdam