react-native的安装与编写hello world

React中文网:http://reactnative.cn/docs/0.30/getting-started.html#contentReact

英文网:http://facebook.github.io/react-native/docs/webview.html

Homebrew安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

如果遇到权限问题运行

sudo chown -R `whoami` /usr/local

React Native的命令行工具:

npm install -g react-native-cli

如果你看到EACCES: permission denied这样的权限报错 运行:

sudo chown -R `whoami` /usr/local

Watchman工具:

brew install watchman

找一个目录下运行初始化

react-native init AwesomeProject  

如果遇到报错或权限问题运行(修复权限):

sudo chmod 777 ~/.babel.json

之后重新运行初始化进入文件夹运行

cd AwesomeProject

react-native run-ios


想要引入外部http请求    

需要用xcode打开本地info.plist把App Transport Security Settings 点开后的  Allow Arbitrary Loads    改成YES


编写Hello World

importReact, {Component} from'react';import{

            AppRegistry,

           Text} from'react-native';

classHelloWorldAppextendsComponent{  render() {return(      Helloworld!    );  }}

// 注意,这里用引号括起来的'HelloWorldApp'必须和你init创建的项目名一致AppRegistry.registerComponent('HelloWorldApp', () =>HelloWorldApp);

你可能感兴趣的:(react-native的安装与编写hello world)