Top Banner
React Native React Meetup 3 - February 11, 2016 - Rob Gietema @robgietema
40

React Native: React Meetup 3

Apr 15, 2017

Download

Internet

Rob Gietema
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: React Native: React Meetup 3

React NativeReact Meetup 3 - February 11, 2016

- Rob Gietema @robgietema

Page 2: React Native: React Meetup 3

Who am I?

Page 3: React Native: React Meetup 3

Why React Native?

Page 4: React Native: React Meetup 3

Native development

Page 5: React Native: React Meetup 3

UIWebView

Page 6: React Native: React Meetup 3

ReactState > Components > DOM

Page 7: React Native: React Meetup 3

React NativeState > Components > DOM, iOS Views, Android Views

Page 8: React Native: React Meetup 3

Learn once write anywhere

Page 9: React Native: React Meetup 3

What does React Native provide?Touch HandlingNative ComponentsStyle & Layout

Page 10: React Native: React Meetup 3

How to installMac OS XHomebrewNode >= 4.0

Page 11: React Native: React Meetup 3

How to installnpm install -g react-native-cli

Page 12: React Native: React Meetup 3

Optionalnpm install watchmen npm install flow

Page 13: React Native: React Meetup 3

iOSInstall Xcode

Page 14: React Native: React Meetup 3

AndroidInstall JDK

Page 15: React Native: React Meetup 3

Androidbrew install android-sdk export ANDROID_HOME=/usr/local/opt/android-sdk

Page 16: React Native: React Meetup 3

Configure SDKandroid

Page 17: React Native: React Meetup 3

Configure SDK

Page 18: React Native: React Meetup 3
Page 19: React Native: React Meetup 3

Configure SDK

Page 20: React Native: React Meetup 3
Page 21: React Native: React Meetup 3

Create Android Virtual Deviceandroid avd

Page 22: React Native: React Meetup 3

Create Android Virtual Device

Page 23: React Native: React Meetup 3
Page 24: React Native: React Meetup 3

Getting startedreact-native init ExampleApp

Page 25: React Native: React Meetup 3

Run Androidreact-native run-android

Page 26: React Native: React Meetup 3

Run iOS

Page 27: React Native: React Meetup 3

ComponentsViewTextListViewScrollViewTextInputNavigatorImage...

Page 28: React Native: React Meetup 3

Components

Page 29: React Native: React Meetup 3

Native modules

Page 30: React Native: React Meetup 3

Frameworks

Page 31: React Native: React Meetup 3

TextInput<TextInput ref="title" autoFocus={true} placeholder={Untitled} style={styles.title} />

<TextInput ref="description" multiline={true} placeholder={Description} style={styles.description} />

Page 32: React Native: React Meetup 3

Button<TouchableOpacity onPress={() => console.log('pressed')}> <View> <Text>Button</Text> </View> </TouchableOpacity>

Page 33: React Native: React Meetup 3

Styles and Layoutconst styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', }, instructions: { textAlign: 'center', marginBottom: 5, }, });

Page 34: React Native: React Meetup 3

Navigator<Navigator initialRoute={{name: 'My First Scene', index: 0}} renderScene={(route, navigator) => // Return view based on route } />

Page 35: React Native: React Meetup 3

Navigator MethodsgetCurrentRoutes() - returns the current list of routes jumpBack() - Jump backward without unmounting the current scene jumpForward() - Jump forward to the next scene in the route stack jumpTo(route) - Transition to an existing scene without unmounting push(route) - Navigate forward to a new scene pop() - Transition back and unmount the current scene replace(route) - Replace the current scene with a new route replaceAtIndex(route, index) - Replace scene specified by index replacePrevious(route) - Replace the previous scene resetTo(route) - Navigate to a new scene and reset route stack immediatelyResetRouteStack(routeStack) - Reset scene with array popToRoute(route) - Pop to a particular scene popToTop() - Pop to the first scene in the stack

Page 36: React Native: React Meetup 3

Fetch datafetch(encodeURI('http://myendpoint')) .then(response => { // Handle data });

Page 37: React Native: React Meetup 3

AsyncStorageasync setMyValue(value) { try { await AsyncStorage.setItem(MY_KEY, value); } catch (error) { // Handle error } }

Page 38: React Native: React Meetup 3

AsyncStorageasync loadMyValue() { try { let notes = await AsyncStorage.getItem(MY_KEY); } catch (error) { // Handle error } }

Page 39: React Native: React Meetup 3

AsyncStorageasync removeValue() { try { await AsyncStorage.removeItem(MY_KEY); } catch (error) { // Handle error } }

Page 40: React Native: React Meetup 3

Questions?slideshare.net/robgietema