React-Native

2016-05-11  本文已影响132人  FortunateStone

Installation

Required Prerequisites

Homebrew

Homebrew, in order to install the required NodeJS, in addition to some recommended installs.

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

Node

Use Homebrew to install Node.js.

NodeJS 4.0 or greater is required for React Native. The default Homebrew package for Node is currently 6.0, so that is not an issue.

brew install node

React Native Command Line Tools

The React Native command line tools allow you to easily create and initialize projects, etc.

npm install -g react-native-cli

If you see the error, EACCES: permission denied, please run the command: sudo npm install -g react-native-cli.

Xcode

Xcode 7.0 or higher. Open the App Store or go to https://developer.apple.com/xcode/downloads/. This will also install git as well.

Highly Recommended Installs

Watchman

Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install it for better performance.

brew install watchman

Flow

Flow, for static typechecking of your React Native code (when using Flow as part of your codebase).

brew install flow

Nuclide

Nuclide is an IDE from Facebook providing a first-class development environment for writing, running and debugging React Native applications.

Get started with Nuclide here.

Testing Installation

react-native init AwesomeProject

cd AwesomeProject

react-native run-ios

You can also open the AwesomeProject folder in Nuclide and run the application, or open ios/AwesomeProject.xcodeproj and hit the Run button in Xcode.

Modifying Project

Now that you successfully started the project, let's modify it:

Open index.ios.js in your text editor of choice (e.g. Nuclide) and edit some lines.

Hit ⌘-R in your iOS simulator to reload the app and see your change!

That's It

Congratulations! You've successfully run and modified your first React Native app.

上一篇下一篇

猜你喜欢

热点阅读