On Facebook React Native

Source: Internet
Author: User
Tags install homebrew install node

This weekend in Upyun's mobile salon, mentioned react Native, write a tutorial today.

The first thing to do is to configure the environment, if not, perform the following work.

1. Install Homebrew Open Terminal

Ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Install node

Brew Install node



3. Installation

Brew Install Watchman



4. Installation

Brew Install Flow


5. Implementation

NPM install-g REACT-NATIVE-CLI

6. Now the CD to your project location-Awesomeproject This is the file you want to create

React-native Init Awesomeproject






Now run the next emulator


OK to finish.

Now open the JS file to write code.



/** * Sample React Native App * https://github.com/facebook/react-native react-native init FaceMash */' use strict ';//used to turn on s trict mode, let JS work better in this mode var React = require (' react-native ');//Load the React-native module in and assign it to the variable React. Require: This concept can be equivalent to "link library" or "Import library" in Swift. Declare some properties var {appregistry, StyleSheet, Text, View, textinput,//input box image,//picture} = React;var FaceMash = React.cre                                 Ateclass ({getinitialstate () {return{                                                                                             Selectedtab: ' FaceMash ' }}, Render:function () {return (//<vi EW style={styles.container}>//<text style={styles.welcome}>//first time with Ah ....            </text>//</View>//Text input box//<view>//       <textinput//     style = {{height:40,backgroundcolor: ' Gray ', borgerwidth:1}}//onchangetext={(text) =>this.setstate ({input : text})}///>//</View>//Set picture//<view>//&L                                    T;image source={require (' image!my_login_qq ')}/>////</view>// Set View <view style={{backgroundcolor: ' #527FE4 ',padding:100}}> <text style={{fontsize:1                                                            1}}> BLue backgroundcolor </Text> </View>  ); }});//define some styles such as color ah, location ah var styles = stylesheet.create ({container: {flex:1, justifycontent: ' Center ', alignit  EMS: ' Center ', backgroundcolor: ' #F5FCFF ',}, welcome: {fontsize:20, textAlign: ' Center ', Margin:10,}, Instructions: {textAlign: ' center ', Color: ' #333333 ', Marginbottom:5,},}),//appregistry defines the portal for the app,and provides the root component. Appregistry.registercomponent (' FaceMash ', () = FaceMash);

The above is some small demo, you can try under.

Yes, if you want to run a real machine, then you need to switch localhost to the IP address of your computer and run it.


Ok


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

On Facebook React Native

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.