- Learn once, write anywhere
- for iOS and Android application development
- Install Node.js
- Install facebook watchman
- Install React Native CLI tool
npm install -g react-native-cli
react-native init BookSearch
- you able to find the BookSearch.xcodeproj
To run your app on iOS:
cd /Users/Scity/Desktop/Programming/github/Onepiece/reactNative/BookSearch
react-native run-ios
- or -
Open ios/BookSearch.xcodeproj in Xcode
Hit the Run button
To run your app on Android:
cd /Users/Scity/Desktop/Programming/github/Onepiece/reactNative/BookSearch
Have an Android emulator running (quickest way to get started), or a device connected
react-native run-android
- Open it in Xcode or
react-native run-ios
- You will find the simulator of iPhone and the terminal
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
<Text style={styles.instructions}>Jackie.Wong</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
- use alert(this.state.name) to pop the window
- use console.log(this.state.name) to print the message on chrome console
- user debugger to set the break point
- Download Atom from website atom.io
- Install "Nuclide"
- Atom -> Preference -> Setting -> Install
- Install Packages "Nuclide" (0.333.0)
- Able to find the "Nuclide" on Aton menu