Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b54b8e06b | ||
|
|
65259d1c4f | ||
|
|
34c034298d | ||
|
|
08f6b2e549 | ||
|
|
673b4609f3 | ||
|
|
72220a33d3 | ||
|
|
01c506f132 | ||
|
|
b47831d2db | ||
|
|
5a6863e2e6 | ||
|
|
791434ae84 | ||
|
|
ce7b1aabb4 | ||
|
|
2a236534cd | ||
|
|
99e40b1430 | ||
|
|
89a3894928 | ||
|
|
8ac9718895 | ||
|
|
13fb5e830c | ||
|
|
0bc5ed2650 | ||
|
|
d8ff7f2d8e | ||
|
|
02f7ef0458 | ||
|
|
874dafcee9 | ||
|
|
17f9d4d246 | ||
|
|
6997817e10 | ||
|
|
dd6df71678 |
@@ -40,8 +40,8 @@ var ComponentExamples: Array<UIExplorerExample> = [
|
||||
module: require('./ModalExample'),
|
||||
},
|
||||
{
|
||||
key: 'PickerAndroidExample',
|
||||
module: require('./PickerAndroidExample'),
|
||||
key: 'PickerExample',
|
||||
module: require('./PickerExample'),
|
||||
},
|
||||
{
|
||||
key: 'ProgressBarAndroidExample',
|
||||
|
||||
@@ -69,6 +69,10 @@ var ComponentExamples: Array<UIExplorerExample> = [
|
||||
key: 'NavigatorIOSExample',
|
||||
module: require('./NavigatorIOSExample'),
|
||||
},
|
||||
{
|
||||
key: 'PickerExample',
|
||||
module: require('./PickerExample'),
|
||||
},
|
||||
{
|
||||
key: 'PickerIOSExample',
|
||||
module: require('./PickerIOSExample'),
|
||||
@@ -144,6 +148,10 @@ var APIExamples: Array<UIExplorerExample> = [
|
||||
key: 'AdSupportIOSExample',
|
||||
module: require('./AdSupportIOSExample'),
|
||||
},
|
||||
{
|
||||
key: 'AlertExample',
|
||||
module: require('./AlertExample').AlertExample,
|
||||
},
|
||||
{
|
||||
key: 'AlertIOSExample',
|
||||
module: require('./AlertIOSExample'),
|
||||
|
||||
@@ -52,7 +52,11 @@ var PickerAndroid = React.createClass({
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return this._stateFromProps(this.props);
|
||||
var state = this._stateFromProps(this.props);
|
||||
return {
|
||||
...state,
|
||||
initialSelectedIndex: state.selectedIndex,
|
||||
};
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
@@ -87,7 +91,7 @@ var PickerAndroid = React.createClass({
|
||||
mode: this.props.mode,
|
||||
onSelect: this._onChange,
|
||||
prompt: this.props.prompt,
|
||||
selected: this.state.selectedIndex,
|
||||
selected: this.state.initialSelectedIndex,
|
||||
testID: this.props.testID,
|
||||
style: [styles.pickerAndroid, this.props.style],
|
||||
};
|
||||
@@ -105,15 +109,24 @@ var PickerAndroid = React.createClass({
|
||||
this.props.onValueChange(null, position);
|
||||
}
|
||||
}
|
||||
this._lastNativePosition = event.nativeEvent.position;
|
||||
this.forceUpdate();
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
this._lastNativePosition = this.state.initialSelectedIndex;
|
||||
},
|
||||
|
||||
componentDidUpdate: function() {
|
||||
// The picker is a controlled component. This means we expect the
|
||||
// on*Change handlers to be in charge of updating our
|
||||
// `selectedValue` prop. That way they can also
|
||||
// disallow/undo/mutate the selection of certain values. In other
|
||||
// words, the embedder of this component should be the source of
|
||||
// truth, not the native component.
|
||||
if (this.refs[REF_PICKER] && this.state.selectedIndex !== event.nativeEvent.position) {
|
||||
if (this.refs[REF_PICKER] && this.state.selectedIndex !== this._lastNativePosition) {
|
||||
this.refs[REF_PICKER].setNativeProps({selected: this.state.selectedIndex});
|
||||
this._lastNativePosition = this.state.selectedIndex;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -21,6 +21,13 @@ NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
@@ -59,10 +59,20 @@ RCT_EXPORT_MODULE()
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
// TODO: if we add an explicit "startObserving" method, we can take this out
|
||||
// of the application startup path
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleLocalNotificationReceived:)
|
||||
name:RCTLocalNotificationReceived
|
||||
|
||||
@@ -4,7 +4,7 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "React"
|
||||
s.version = package['version']
|
||||
s.version = "0.26.0"
|
||||
s.summary = package['description']
|
||||
s.description = <<-DESC
|
||||
React Native apps are built using the React JS
|
||||
|
||||
@@ -308,7 +308,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
||||
|
||||
// The executor is a bridge module, but we want it to be instantiated before
|
||||
// any other module has access to the bridge, in case they need the JS thread.
|
||||
// TODO: once we have more fine-grained control of init (D3175632) we can
|
||||
// TODO: once we have more fine-grained control of init (t11106126) we can
|
||||
// probably just replace this with [self moduleForClass:self.executorClass]
|
||||
if (!_javaScriptExecutor) {
|
||||
id<RCTJavaScriptExecutor> executorModule = [self.executorClass new];
|
||||
|
||||
@@ -19,6 +19,13 @@ static NSDictionary *RCTParseKeyboardNotification(NSNotification *notification);
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
@@ -116,6 +116,13 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
@@ -43,7 +43,7 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (D3175632): Remove once we have more declarative control over module setup.
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,20 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
// TODO: if we add an explicit "startObserving" method, we can take this out
|
||||
// of the application startup path
|
||||
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:self selector:@selector(applicationDidChangeStatusBarFrame:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
||||
[nc addObserver:self selector:@selector(applicationWillChangeStatusBarFrame:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
||||
|
||||
@@ -128,7 +128,7 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (D3175632): Remove once we have more declarative control over module setup.
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION_NAME=1000.0.0-master
|
||||
VERSION_NAME=0.26.0
|
||||
GROUP=com.facebook.react
|
||||
|
||||
POM_NAME=ReactNative
|
||||
|
||||
@@ -277,7 +277,9 @@ void JSCExecutor::flush() {
|
||||
|
||||
if (!ensureBatchedBridgeObject()) {
|
||||
throwJSExecutionException(
|
||||
"Couldn't get the native call queue: bridge configuration isn't available. This shouldn't be possible. Congratulations.");
|
||||
"Couldn't get the native call queue: bridge configuration isn't available. This "
|
||||
"probably indicates there was an issue loading the JS bundle, e.g. it wasn't packaged "
|
||||
"into the app or was malformed. Check your logs (`adb logcat`) for more information.");
|
||||
}
|
||||
|
||||
std::string calls = m_flushedQueueObj->callAsFunction().toJSONString();
|
||||
|
||||
@@ -50,7 +50,7 @@ test:
|
||||
# eslint bot
|
||||
- cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js
|
||||
# JS tests for dependencies installed with npm3
|
||||
- npm run flow check
|
||||
# - npm run flow check
|
||||
- npm test -- --maxWorkers=1
|
||||
|
||||
# build app
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
---
|
||||
id: android-setup
|
||||
title: Android Setup
|
||||
layout: docs
|
||||
category: Quick Start
|
||||
permalink: docs/android-setup.html
|
||||
next: linux-windows-support
|
||||
---
|
||||
|
||||
This guide describes basic steps of the Android development environment setup that are required to run React Native android apps on an android emulator.
|
||||
|
||||
### Install Git
|
||||
|
||||
- **On Mac**, if you have installed [XCode](https://developer.apple.com/xcode/), Git is already installed, otherwise run the following:
|
||||
|
||||
brew install git
|
||||
|
||||
- **On Linux**, install Git [via your package manager](https://git-scm.com/download/linux).
|
||||
|
||||
- **On Windows**, download and install [Git for Windows](https://git-for-windows.github.io/). During the setup process, choose "Run Git from Windows Command Prompt", which will add Git to your `PATH` environment variable.
|
||||
|
||||
### Install the Android SDK (unless you already have it)
|
||||
|
||||
1. [Install the latest JDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
|
||||
2. Install the Android SDK:
|
||||
- **On Mac**: `brew install android-sdk`
|
||||
- **On Linux and Windows**: [Download from the Android website](https://developer.android.com/sdk/installing/index.html)
|
||||
|
||||
### Define the ANDROID_HOME environment variable
|
||||
|
||||
__IMPORTANT__: Make sure the `ANDROID_HOME` environment variable points to your existing Android SDK:
|
||||
|
||||
- **On Mac**, add this to your `~/.bashrc`, `~/.bash_profile` or whatever your shell uses:
|
||||
|
||||
# If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
|
||||
export ANDROID_HOME=/usr/local/opt/android-sdk
|
||||
- **On Linux**, add this to your `~/.bashrc`, `~/.bash_profile` or whatever your shell uses:
|
||||
|
||||
export ANDROID_HOME=<path_where_you_unpacked_android_sdk>
|
||||
|
||||
- **On Windows**, go to `Control Panel` -> `System and Security` -> `System` -> `Change settings` -> `Advanced` -> `Environment variables` -> `New`
|
||||
|
||||
__NOTE__: You need to restart the Command Prompt (Windows) / Terminal Emulator (Mac OS X, Linux) to apply the new Environment variables.
|
||||
|
||||
|
||||
### Use gradle daemon
|
||||
|
||||
React Native Android use [gradle](https://docs.gradle.org) as a build system. We recommend to enable gradle daemon functionality which may result in up to 50% improvement in incremental build times for changes in java code. Learn [here](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) how to enable it for your platform.
|
||||
|
||||
### Configure your SDK
|
||||
|
||||
1. Open the Android SDK Manager (**on Mac** start a new shell and run `android`); in the window that appears make sure you check:
|
||||
* Android SDK Build-tools version 23.0.**1**
|
||||
* Android 6.0 (API 23)
|
||||
* Local Maven repository for Support Libraries (this is called Android Support Repository in older versions)
|
||||
2. Click "Install Packages"
|
||||
|
||||
 
|
||||
|
||||
### Install Genymotion
|
||||
|
||||
Genymotion is much easier to set up than stock Google emulators. However, it's only free for personal use. If you want to use the stock Google emulator, see below.
|
||||
|
||||
1. Download and install [Genymotion](https://www.genymotion.com/).
|
||||
2. Open Genymotion. It might ask you to install VirtualBox unless you already have it.
|
||||
3. Create a new emulator and start it.
|
||||
4. To bring up the developer menu press ⌘+M
|
||||
|
||||
### Alternative: Create a stock Google emulator
|
||||
|
||||
1. Start a new shell and run `android`; in the window that appears make sure you check:
|
||||
* Intel x86 Atom System Image (for Android 5.1.1 - API 22)
|
||||
* Intel x86 Emulator Accelerator (HAXM installer)
|
||||
2. Click "Install Packages".
|
||||
3. [Configure hardware acceleration (HAXM)](http://developer.android.com/tools/devices/emulator.html#vm-mac), otherwise the emulator is going to be slow (or may not run at all).
|
||||
* On a mac this is typically requires opening: `/usr/local/opt/android-sdk/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM_<version>.dmg` and installing the package within.
|
||||
4. Create an Android Virtual Device (AVD):
|
||||
1. Run `android avd` and click on **Create...**
|
||||

|
||||
2. With the new AVD selected, click `Start...`
|
||||
5. To bring up the developer menu press F2 (or ⌘+M for Android Studio 2.0 or newer)
|
||||
6. Install [Frappé](http://getfrappe.com) (OSX only)
|
||||
|
||||
### Windows Hyper-V Alternative
|
||||
|
||||
The [Visual Studio Emulator for Android](https://www.visualstudio.com/en-us/features/msft-android-emulator-vs.aspx) is a free android emulator that is hardware accelerated via Hyper-V. It doesn't require you to install Visual Studio at all.
|
||||
|
||||
To use it with react-native you just have to add a key and value to your registry:
|
||||
|
||||
1. Open the Run Command (Windows+R)
|
||||
2. Enter `regedit.exe`
|
||||
3. In the Registry Editor navigate to `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools`
|
||||
4. Right Click on `Android SDK Tools` and choose `New > String Value`
|
||||
5. Set the name to `Path`
|
||||
6. Double Click the new `Path` Key and set the value to `C:\Program Files\Android\sdk`. The path value might be different on your machine.
|
||||
|
||||
You will also need to run the command `adb reverse tcp:8081 tcp:8081` with this emulator.
|
||||
|
||||
Then restart the emulator and when it runs you can just do `react-native run-android` as usual.
|
||||
|
||||
### Editing your app's Java code in Android Studio
|
||||
|
||||
You can use any editor to edit JavaScript. If you want to use Android Studio to work on native code, from the Welcome screen of Android Studio choose "Import project" and select the `android` folder of your app.
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
In case you encounter
|
||||
|
||||
```
|
||||
Execution failed for task ':app:installDebug'.
|
||||
com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
|
||||
```
|
||||
|
||||
try downgrading your Gradle version to 1.2.3 in `<project-name>/android/build.gradle` (https://github.com/facebook/react-native/issues/2720)
|
||||
@@ -4,71 +4,811 @@ title: Getting Started
|
||||
layout: docs
|
||||
category: Quick Start
|
||||
permalink: docs/getting-started.html
|
||||
next: getting-started-linux
|
||||
next: tutorial
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
1. OS X - This guide assumes OS X which is needed for iOS development.
|
||||
2. [Homebrew](http://brew.sh/) is the recommended way to install Watchman and Flow.
|
||||
3. Install [Node.js](https://nodejs.org/) 4.0 or newer.
|
||||
- Install **nvm** with [its setup instructions here](https://github.com/creationix/nvm#installation). Then run `nvm install node && nvm alias default node`, which installs the latest version of Node.js and sets up your terminal so you can run it by typing `node`. With nvm you can install multiple versions of Node.js and easily switch between them.
|
||||
- New to [npm](https://docs.npmjs.com/)?
|
||||
4. `brew install watchman`. We recommend installing [watchman](https://facebook.github.io/watchman/docs/install.html), otherwise you might hit a node file watching bug.
|
||||
5. `brew install flow`, if you want to use [flow](http://www.flowtype.org).
|
||||
<div class="toggler">
|
||||
<style>
|
||||
.toggler a {
|
||||
display: inline-block;
|
||||
padding: 10px 5px;
|
||||
margin: 2px;
|
||||
border: 1px solid #05A5D1;
|
||||
border-radius: 3px;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
.display-os-mac .toggler .button-mac,
|
||||
.display-os-linux .toggler .button-linux,
|
||||
.display-os-windows .toggler .button-windows,
|
||||
.display-platform-ios .toggler .button-ios,
|
||||
.display-platform-android .toggler .button-android {
|
||||
background-color: #05A5D1;
|
||||
color: white;
|
||||
}
|
||||
block { display: none; }
|
||||
.display-platform-ios.display-os-mac .ios.mac,
|
||||
.display-platform-ios.display-os-linux .ios.linux,
|
||||
.display-platform-ios.display-os-windows .ios.windows,
|
||||
.display-platform-android.display-os-mac .android.mac,
|
||||
.display-platform-android.display-os-linux .android.linux,
|
||||
.display-platform-android.display-os-windows .android.windows {
|
||||
display: block;
|
||||
}</style>
|
||||
<span>Platform:</span>
|
||||
<a href="javascript:void(0);" class="button-ios" onclick="display('platform', 'ios')">iOS</a>
|
||||
<a href="javascript:void(0);" class="button-android" onclick="display('platform', 'android')">Android</a>
|
||||
<span>OS:</span>
|
||||
<a href="javascript:void(0);" class="button-mac" onclick="display('os', 'mac')">Mac</a>
|
||||
<a href="javascript:void(0);" class="button-linux" onclick="display('os', 'linux')">Linux</a>
|
||||
<a href="javascript:void(0);" class="button-windows" onclick="display('os', 'windows')">Windows</a>
|
||||
</div>
|
||||
|
||||
We recommend periodically running `brew update && brew upgrade` to keep your programs up-to-date.
|
||||
<!-- ######### LINUX AND WINDOWS for iOS ##################### -->
|
||||
|
||||
## iOS Setup
|
||||
<block class="linux windows ios" />
|
||||
|
||||
[Xcode](https://developer.apple.com/xcode/downloads/) 7.0 or higher is required. It can be installed from the App Store.
|
||||
## Unsupported
|
||||
|
||||
## Android Setup
|
||||
<div>Unfortunately, Apple only lets you develop for iOS on a Mac machine. Please check out the <a href="" onclick="display('platform', 'android')">Android</a> instructions instead.</div>
|
||||
|
||||
To write React Native apps for Android, you will need to install the Android SDK (and an Android emulator if you want to work on your app without having to use a physical device). See [Android setup guide](docs/android-setup.html) for instructions on how to set up your Android environment.
|
||||
<center><img src="img/react-native-sorry-not-supported.png" width="150"></img></center>
|
||||
|
||||
_NOTE:_ There is experimental [Windows and Linux support](docs/linux-windows-support.html) for Android development.
|
||||
<!-- ######### MAC for iOS ##################### -->
|
||||
|
||||
## Quick start
|
||||
<block class="mac ios android" />
|
||||
|
||||
Install the React Native command line tools:
|
||||
## Installation
|
||||
|
||||
$ npm install -g react-native-cli
|
||||
### Required Prerequisites
|
||||
|
||||
__NOTE__: If you see the error, `EACCES: permission denied`, please run the command: `sudo npm install -g react-native-cli`.
|
||||
#### Homebrew
|
||||
|
||||
Create a React Native project:
|
||||
[Homebrew](http://brew.sh/), in order to install the required NodeJS, in addition to some
|
||||
recommended installs.
|
||||
|
||||
$ react-native init AwesomeProject
|
||||
```
|
||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
```
|
||||
|
||||
#### Node
|
||||
|
||||
Use Homebrew to install [Node.js](https://nodejs.org/).
|
||||
|
||||
> 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`.
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
#### Xcode
|
||||
|
||||
[Xcode](https://developer.apple.com/xcode/downloads/) 7.0 or higher. Open the App Store or go to https://developer.apple.com/xcode/downloads/. This will also install `git` as well.
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
#### Android Studio
|
||||
|
||||
[Android Studio](http://developer.android.com/sdk/index.html) 2.0 or higher.
|
||||
|
||||
> Android Studio requires the Java Development Kit [JDK] 1.8 or higher. You can type
|
||||
> `javac -version` to see what version you have, if any. If you do not meet the JDK requirement,
|
||||
> you can
|
||||
> [download it](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
|
||||
|
||||
Android Studio will provide you the Android SDK and emulator required to run and test your React
|
||||
Native apps.
|
||||
|
||||
> Unless otherwise mentioned, keep all the setup defaults intact. For example, the
|
||||
> `Android Support Repository` is installed automatically with Android Studio, and we need that
|
||||
> for React Native.
|
||||
|
||||
You will need to customize your installation:
|
||||
|
||||
- Choose a `Custom` installation
|
||||
|
||||

|
||||
|
||||
- Choose both `Performance` and `Android Virtual Device`
|
||||
|
||||

|
||||
|
||||
- After installation, choose `Configure | SDK Manager` from the Android Studio welcome window.
|
||||
|
||||

|
||||
|
||||
- In the `SDK Platforms` window, choose `Show Package Details` and under `Android 6.0 (Marshmallow)`, make sure that `Google APIs`, `Intel x86 Atom System Image`, `Intel x86 Atom_64 System Image`, and `Google APIs Intel x86 Atom_64 System Image` are checked.
|
||||
|
||||

|
||||
|
||||
- In the `SDK Tools` window, choose `Show Package Details` and under `Android SDK Build Tools`, make sure that `Android SDK Build-Tools 23.0.1` is selected.
|
||||
|
||||

|
||||
|
||||
#### ANDROID_HOME Environment Variable
|
||||
|
||||
Ensure the `ANDROID_HOME` environment variable points to your existing Android SDK. To do that, add
|
||||
this to your `~/.bashrc`, `~/.bash_profile` (or whatever your shell uses) and re-open your terminal:
|
||||
|
||||
```
|
||||
# If you installed the SDK without Android Studio, then it may be something like:
|
||||
# /usr/local/opt/android-sdk
|
||||
export ANDROID_HOME=~/Library/Android/sdk
|
||||
```
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
### Highly Recommended Installs
|
||||
|
||||
#### Watchman
|
||||
|
||||
[Watchman](https://facebook.github.io/watchman/docs/install.html) 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](http://www.flowtype.org), for static typechecking of your React Native code (when using
|
||||
Flow as part of your codebase).
|
||||
|
||||
|
||||
**To run the iOS app:**
|
||||
```
|
||||
brew install flow
|
||||
```
|
||||
|
||||
- `$ cd AwesomeProject`
|
||||
- `$ react-native run-ios` **OR** open `ios/AwesomeProject.xcodeproj` and hit "Run" button in Xcode
|
||||
- Open `index.ios.js` in your text editor of choice and edit some lines.
|
||||
<block class="mac android" />
|
||||
|
||||
#### Add Android Tools Directory to your `PATH`
|
||||
|
||||
You can add the Android tools directory on your `PATH` in case you need to run any of the Android
|
||||
tools from the command line such as `android avd`. In your `~/.bash` or `~/.bash_profile`:
|
||||
|
||||
```
|
||||
# Your exact string here may be different.
|
||||
PATH="~/Library/Android/sdk/tools:~/Library/Android/sdk/platform-tools:${PATH}"
|
||||
export PATH
|
||||
```
|
||||
|
||||
#### Gradle Daemon
|
||||
|
||||
Enable [Gradle Daemon](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) which greatly improves incremental build times for changes in java code.
|
||||
|
||||
### Other Optional Installs
|
||||
|
||||
#### Git
|
||||
|
||||
Git version control. If you have installed [Xcode](https://developer.apple.com/xcode/), Git is
|
||||
already installed, otherwise run the following:
|
||||
|
||||
```
|
||||
brew install git
|
||||
```
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
#### Nuclide
|
||||
|
||||
[Nuclide](http://nuclide.io) is an IDE from Facebook providing a first-class development environment
|
||||
for writing, [running](http://nuclide.io/docs/platforms/react-native/#running-applications) and
|
||||
[debugging](http://nuclide.io/docs/platforms/react-native/#debugging)
|
||||
[React Native](http://nuclide.io/docs/platforms/react-native/) applications.
|
||||
|
||||
Get started with Nuclide [here](http://nuclide.io/docs/quick-start/getting-started/).
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
#### Genymotion
|
||||
|
||||
Genymotion is an alternative to the stock Google emulator that comes with Android Studio.
|
||||
However, it's only free for personal use. If you want to use the stock Google emulator, see below.
|
||||
|
||||
1. Download and install [Genymotion](https://www.genymotion.com/).
|
||||
2. Open Genymotion. It might ask you to install VirtualBox unless you already have it.
|
||||
3. Create a new emulator and start it.
|
||||
4. To bring up the developer menu press ⌘+M
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Virtual Device Not Created When Installing Android Studio
|
||||
|
||||
There is a [known bug](https://code.google.com/p/android/issues/detail?id=207563) on some versions
|
||||
of Android Studio where a virtual device will not be created, even though you selected it in the
|
||||
installation sequence. You may see this at the end of the installation:
|
||||
|
||||
```
|
||||
Creating Android virtual device
|
||||
Unable to create a virtual device: Unable to create Android virtual device
|
||||
```
|
||||
|
||||
If you see this, run `android avd` and create the virtual device manually.
|
||||
|
||||

|
||||
|
||||
Then select the new device in the AVD Manager window and click `Start...`.
|
||||
|
||||
#### Shell Command Unresponsive Exception
|
||||
|
||||
If you encounter:
|
||||
|
||||
```
|
||||
Execution failed for task ':app:installDebug'.
|
||||
com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
|
||||
```
|
||||
|
||||
try downgrading your Gradle version to 1.2.3 in `<project-name>/android/build.gradle` (https://github.com/facebook/react-native/issues/2720)
|
||||
|
||||
|
||||
<!-- ######### LINUX and WINDOWS for ANDROID ##################### -->
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
## Installation
|
||||
|
||||
### Required Prerequisites
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
#### Chocolatey
|
||||
|
||||
[Chocolatey](https://chocolatey.org) is a package manager for Windows similar to `yum` and
|
||||
`apt-get`. See the [website](https://chocolatey.org) for updated instructions, but installing from
|
||||
the Terminal should be something like:
|
||||
|
||||
```
|
||||
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
|
||||
```
|
||||
|
||||
> Normally when you run Chocolatey to install a package, you should run your Terminal as
|
||||
> Administrator.
|
||||
|
||||
#### Python 2
|
||||
|
||||
Fire up the Termimal and use Chocolatey to install Python 2.
|
||||
|
||||
> Python 3 will currently not work when initializing a React Native project.
|
||||
|
||||
```
|
||||
choco install python2
|
||||
```
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
#### Node
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
Fire up the Terminal and type the following commands to install NodeJS from the NodeSource
|
||||
repository:
|
||||
|
||||
```
|
||||
sudo apt-get install -y build-essential
|
||||
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||
```
|
||||
|
||||
<block class='windows android' />
|
||||
|
||||
Fire up the Termimal and use Chocolatey to install NodeJS.
|
||||
|
||||
```
|
||||
choco install nodejs.install
|
||||
```
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
#### 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`.
|
||||
|
||||
#### Android Studio
|
||||
|
||||
[Android Studio](http://developer.android.com/sdk/index.html) 2.0 or higher.
|
||||
|
||||
> Android Studio requires the Java Development Kit [JDK] 1.8 or higher. You can type
|
||||
> `javac -version` to see what version you have, if any. If you do not meet the JDK requirement,
|
||||
> you can
|
||||
> [download it](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html),
|
||||
> or use a pacakage manager to install it (e.g. `choco install jdk8`,
|
||||
> `apt-get install default-jdk`).
|
||||
|
||||
Android Studio will provide you the Android SDK and emulator required to run and test your React
|
||||
Native apps.
|
||||
|
||||
> Unless otherwise mentioned, keep all the setup defaults intact. For example, the
|
||||
> `Android Support Repository` is installed automatically with Android Studio, and we need that
|
||||
> for React Native.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
You will need to customize your installation:
|
||||
|
||||
- Choose a `Custom` installation
|
||||
|
||||

|
||||
|
||||
- Choose `Android Virtual Device`
|
||||
|
||||

|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
- Make sure all components are checked for the install, particularly the `Android SDK` and `Android Device Emulator`.
|
||||
|
||||
- After the initial install, choose a `Custom` installation.
|
||||
|
||||

|
||||
|
||||
- Verify installed components, particularly the emulator and the HAXM accelerator. They should be checked.
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
- After installation, choose `Configure | SDK Manager` from the Android Studio welcome window.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
- In the `SDK Platforms` window, choose `Show Package Details` and under `Android 6.0 (Marshmallow)`, make sure that `Google APIs`, `Intel x86 Atom System Image`, `Intel x86 Atom_64 System Image`, and `Google APIs Intel x86 Atom_64 System Image` are checked.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
- In the `SDK Tools` window, choose `Show Package Details` and under `Android SDK Build Tools`, make sure that `Android SDK Build-Tools 23.0.1` is selected.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
#### ANDROID_HOME Environment Variable
|
||||
|
||||
Ensure the `ANDROID_HOME` environment variable points to your existing Android SDK.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
To do that, add this to your `~/.bashrc`, `~/.bash_profile` (or whatever your shell uses) and
|
||||
re-open your terminal:
|
||||
|
||||
```
|
||||
# If you installed the SDK without Android Studio, then it may be something like:
|
||||
# /usr/local/opt/android-sdk; Generally with Android Studio, the SDK is installed here...
|
||||
export ANDROID_HOME=~/Android/Sdk
|
||||
```
|
||||
|
||||
> You need to restart the Terminal to apply the new environment variables (or `source` the relevant
|
||||
> bash file).
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
Go to `Control Panel` -> `System and Security` -> `System` -> `Change settings` ->
|
||||
`Advanced System Settings` -> `Environment variables` -> `New`
|
||||
|
||||
> Your path to the SDK will vary to the one shown below.
|
||||
|
||||

|
||||
|
||||
> You need to restart the Command Prompt (Windows) to apply the new environment variables.
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
### Highly Recommended Installs
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
#### Watchman
|
||||
|
||||
Watchman is a tool by Facebook for watching changes in the filesystem. It is recommended you install
|
||||
it for better performance.
|
||||
|
||||
> This also helps avoid a node file-watching bug.
|
||||
|
||||
Type the following into your terminal to compile watchman from source and install it:
|
||||
|
||||
```
|
||||
git clone https://github.com/facebook/watchman.git
|
||||
cd watchman
|
||||
git checkout v4.5.0 # the latest stable release
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
#### Flow
|
||||
|
||||
[Flow](http://www.flowtype.org), for static typechecking of your React Native code (when using
|
||||
Flow as part of your codebase).
|
||||
|
||||
Type the following in the terminal:
|
||||
|
||||
```
|
||||
npm install -g flow-bin
|
||||
```
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
#### Gradle Daemon
|
||||
|
||||
Enable [Gradle Daemon](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) which greatly
|
||||
improves incremental build times for changes in java code.
|
||||
|
||||
<block class="mac linux android" />
|
||||
|
||||
```
|
||||
touch ~/.gradle/gradle.properties && echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties
|
||||
```
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
```
|
||||
(if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties")
|
||||
```
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
#### Android Emulator Accelerator
|
||||
|
||||
You may have seen the following screen when installing Android Studio.
|
||||
|
||||

|
||||
|
||||
If your system supports KVM, you should install the
|
||||
[Intel Android Emulator Accelerator](https://software.intel.com/en-us/android/articles/speeding-up-the-android-emulator-on-intel-architecture#_Toc358213272).
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
#### Add Android Tools Directory to your `PATH`
|
||||
|
||||
You can add the Android tools directory on your `PATH` in case you need to run any of the Android
|
||||
tools from the command line such as `android avd`.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
In your `~/.bashrc` or `~/.bash_profile`:
|
||||
|
||||
```
|
||||
# Your exact string here may be different.
|
||||
PATH="~/Android/Sdk/tools:~/Android/Sdk/platform-tools:${PATH}"
|
||||
export PATH
|
||||
```
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
Go to `Control Panel` -> `System and Security` -> `System` -> `Change settings` ->
|
||||
`Advanced System Settings` -> `Environment variables` -> highlight `PATH` -> `Edit...`
|
||||
|
||||
> The location of your Android tools directories will vary.
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
### Other Optional Installs
|
||||
|
||||
#### Git
|
||||
|
||||
<block class="linux android">
|
||||
|
||||
Install Git [via your package manager](https://git-scm.com/download/linux)
|
||||
(e.g., `sudo apt-get install git-all`).
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
You can use Chocolatey to install `git` via:
|
||||
|
||||
```
|
||||
choco install git
|
||||
```
|
||||
|
||||
Alternatively, you can download and install [Git for Windows](https://git-for-windows.github.io/).
|
||||
During the setup process, choose "Run Git from Windows Command Prompt", which will add `git` to your
|
||||
`PATH` environment variable.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
#### Nuclide
|
||||
|
||||
[Nuclide] is an IDE from Facebook providing a first-class development environment for writing,
|
||||
[running](http://nuclide.io/docs/platforms/react-native/#running-applications) and
|
||||
[debugging](http://nuclide.io/docs/platforms/react-native/#debugging)
|
||||
[React Native](http://nuclide.io/docs/platforms/react-native/) applications.
|
||||
|
||||
Get started with Nuclide [here](http://nuclide.io/docs/quick-start/getting-started/).
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
#### Genymotion
|
||||
|
||||
Genymotion is an alternative to the stock Google emulator that comes with Android Studio.
|
||||
However, it's only free for personal use. If you want to use the stock Google emulator, see below.
|
||||
|
||||
1. Download and install [Genymotion](https://www.genymotion.com/).
|
||||
2. Open Genymotion. It might ask you to install VirtualBox unless you already have it.
|
||||
3. Create a new emulator and start it.
|
||||
4. To bring up the developer menu press ⌘+M
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
#### Visual Studio Emulator for Android
|
||||
|
||||
The [Visual Studio Emulator for Android](https://www.visualstudio.com/en-us/features/msft-android-emulator-vs.aspx)
|
||||
is a free android emulator that is hardware accelerated via Hyper-V. It is an alternative to the
|
||||
stock Google emulator that comes with Android Studio. It doesn't require you to install Visual
|
||||
Studio at all.
|
||||
|
||||
To use it with react-native you just have to add a key and value to your registry:
|
||||
|
||||
1. Open the Run Command (Windows+R)
|
||||
2. Enter `regedit.exe`
|
||||
3. In the Registry Editor navigate to `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools`
|
||||
4. Right Click on `Android SDK Tools` and choose `New > String Value`
|
||||
5. Set the name to `Path`
|
||||
6. Double Click the new `Path` Key and set the value to `C:\Program Files\Android\sdk`. The path value might be different on your machine.
|
||||
|
||||
You will also need to run the command `adb reverse tcp:8081 tcp:8081` with this emulator.
|
||||
|
||||
Then restart the emulator and when it runs you can just do `react-native run-android` as usual.
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Unable to run mksdcard SDK Tool
|
||||
|
||||
When installing Android Studio, if you get the error:
|
||||
|
||||
```
|
||||
Unable to run mksdcard SDK tool
|
||||
```
|
||||
|
||||
then install the standard C++ library:
|
||||
|
||||
```
|
||||
sudo apt-get install lib32stdc++6
|
||||
```
|
||||
|
||||
#### Virtual Device Not Created When Installing Android Studio
|
||||
|
||||
There is a [known bug](https://code.google.com/p/android/issues/detail?id=207563) on some versions
|
||||
of Android Studio where a virtual device will not be created, even though you selected it in the
|
||||
installation sequence. You may see this at the end of the installation:
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
```
|
||||
Creating Android virtual device
|
||||
Unable to create a virtual device: Unable to create Android virtual device
|
||||
```
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
If you see this, run `android avd` and create the virtual device manually.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows android" />
|
||||
|
||||

|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
Then select the new device in the AVD Manager window and click `Start...`.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
#### Shell Command Unresponsive Exception
|
||||
|
||||
In case you encounter
|
||||
|
||||
```
|
||||
Execution failed for task ':app:installDebug'.
|
||||
com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
|
||||
```
|
||||
|
||||
try downgrading your Gradle version to 1.2.3 in `<project-name>/android/build.gradle` (https://github.com/facebook/react-native/issues/2720)
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
## Testing Installation
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
cd AwesomeProject
|
||||
react-native run-ios
|
||||
```
|
||||
|
||||
> You can also
|
||||
> [open the `AwesomeProject`](http://nuclide.io/docs/quick-start/getting-started/#adding-a-project)
|
||||
> folder in [Nuclide](http://nuclide.io) and
|
||||
> [run the application](http://nuclide.io/docs/platforms/react-native/#command-line), or open
|
||||
> `ios/AwesomeProject.xcodeproj` and hit the `Run` button in Xcode.
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
cd AwesomeProject
|
||||
react-native run-android
|
||||
```
|
||||
|
||||
> You can also
|
||||
> [open the `AwesomeProject`](http://nuclide.io/docs/quick-start/getting-started/#adding-a-project)
|
||||
> folder in [Nuclide](http://nuclide.io) and
|
||||
> [run the application](http://nuclide.io/docs/platforms/react-native/#command-line).
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
### Modifying Project
|
||||
|
||||
Now that you successfully started the project, let's modify it:
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
- Open `index.ios.js` in your text editor of choice (e.g. [Nuclide](http://nuclide.io/docs/platforms/react-native/)) and edit some lines.
|
||||
- Hit ⌘-R in your iOS simulator to reload the app and see your change!
|
||||
|
||||
_Note: If you are using an iOS device, see the [Running on iOS Device page](docs/running-on-device-ios.html#content)._
|
||||
<block class="mac android" />
|
||||
|
||||
**To run the Android app:**
|
||||
|
||||
- `$ cd AwesomeProject`
|
||||
- `$ react-native run-android`
|
||||
- Open `index.android.js` in your text editor of choice and edit some lines.
|
||||
- Press the menu button (F2/⌘-M by default, depending on AVD version, or ⌘-M in Genymotion) and select *Reload JS* (or press R twice) to see your change!
|
||||
- Open `index.android.js` in your text editor of choice (e.g. [Nuclide](http://nuclide.io/docs/platforms/react-native/)) and edit some lines.
|
||||
- Press the `R` key twice **OR** open the menu (F2 by default, or ⌘-M in Genymotion) and select Reload JS to see your change!
|
||||
- Run `adb logcat *:S ReactNative:V ReactNativeJS:V` in a terminal to see your app's logs
|
||||
|
||||
_Note: If you are using an Android device, see the [Running on Android Device page](docs/running-on-device-android.html#content)._
|
||||
<block class="mac ios android" />
|
||||
|
||||
### That's It
|
||||
|
||||
Congratulations! You've successfully run and modified your first React Native app.
|
||||
|
||||
_If you run into any issues getting started, see the [troubleshooting page](docs/troubleshooting.html#content)._
|
||||
<center><img src="img/react-native-congratulations.png" width="150"></img></center>
|
||||
|
||||
## Adding Android to an existing React Native project
|
||||
<block class="windows linux android" />
|
||||
|
||||
If you already have a (iOS-only) React Native project and want to add Android support, you need to execute the following commands in your existing project directory:
|
||||
## Testing Installation
|
||||
|
||||
1. Update the `react-native` dependency in your `package.json` file to [the latest version](https://www.npmjs.com/package/react-native)
|
||||
2. `$ npm install`
|
||||
3. `$ react-native android`
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
cd AwesomeProject
|
||||
react-native run-android
|
||||
```
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
### Troubleshooting Run
|
||||
|
||||
A common issue is that the packager is not started automatically when you run
|
||||
`react-native run-android`. You can start it manually using:
|
||||
|
||||
```
|
||||
cd AwesomeProject
|
||||
react-native start
|
||||
```
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
Or if you hit a `ERROR Watcher took too long to load` on Windows, try increasing the timeout in [this file](https://github.com/facebook/react-native/blob/5fa33f3d07f8595a188f6fe04d6168a6ede1e721/packager/react-packager/src/DependencyResolver/FileWatcher/index.js#L16) (under your `node_modules/react-native/`).
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
### Modifying Project
|
||||
|
||||
Now that you successfully started the project, let's modify it:
|
||||
|
||||
- Open `index.android.js` in your text editor of choice (e.g. [Nuclide](http://nuclide.io/docs/platforms/react-native/)) and edit some lines.
|
||||
- Press the `R` key twice **OR** open the menu (F2 by default, or ctrl-M in the emulator) and select Reload JS to see your change!
|
||||
- Run `adb logcat *:S ReactNative:V ReactNativeJS:V` in a terminal to see your app's logs
|
||||
|
||||
### That's It
|
||||
|
||||
Congratulations! You've successfully run and modified your first React Native app.
|
||||
|
||||
<center><img src="img/react-native-congratulations.png" width="150"></img></center>
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
## Common Followups
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
- If you want to run on a physical device, see the [Running on iOS Device page](docs/running-on-device-ios.html#content).
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
- If you want to run on a physical device, see the [Running on Android Device page](docs/running-on-device-android.html#content).
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
- If you run into any issues getting started, see the [Troubleshooting page](docs/troubleshooting.html#content).
|
||||
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
## Common Followups
|
||||
|
||||
- If you want to run on a physical device, see the [Running on Android Device page](docs/running-on-device-android.html#content).
|
||||
|
||||
- If you run into any issues getting started, see the [Troubleshooting page](docs/troubleshooting.html#content).
|
||||
|
||||
<script>
|
||||
// Convert <div>...<span><block /></span>...</div>
|
||||
// Into <div>...<block />...</div>
|
||||
var blocks = document.getElementsByTagName('block');
|
||||
for (var i = 0; i < blocks.length; ++i) {
|
||||
var block = blocks[i];
|
||||
var span = blocks[i].parentNode;
|
||||
var container = span.parentNode;
|
||||
container.insertBefore(block, span);
|
||||
container.removeChild(span);
|
||||
}
|
||||
// Convert <div>...<block />content<block />...</div>
|
||||
// Into <div>...<block>content</block><block />...</div>
|
||||
blocks = document.getElementsByTagName('block');
|
||||
for (var i = 0; i < blocks.length; ++i) {
|
||||
var block = blocks[i];
|
||||
while (block.nextSibling && block.nextSibling.tagName !== 'BLOCK') {
|
||||
block.appendChild(block.nextSibling);
|
||||
}
|
||||
}
|
||||
function display(type, value) {
|
||||
var container = document.getElementsByTagName('block')[0].parentNode;
|
||||
container.className = 'display-' + type + '-' + value + ' ' +
|
||||
container.className.replace(RegExp('display-' + type + '-[a-z]+ ?'), '');
|
||||
event && event.preventDefault();
|
||||
}
|
||||
var isMac = navigator.platform === 'MacIntel';
|
||||
var isWindows = navigator.platform === 'Win32';
|
||||
display('os', isMac ? 'mac' : (isWindows ? 'windows' : 'linux'));
|
||||
display('platform', isMac ? 'ios' : 'android');
|
||||
</script>
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
---
|
||||
id: getting-started-linux
|
||||
title: Getting Started on Linux
|
||||
layout: docs
|
||||
category: Quick Start
|
||||
permalink: docs/getting-started-linux.html
|
||||
next: android-setup
|
||||
---
|
||||
|
||||
This guide is essentially a beginner-friendly version of the [Getting Started](/react-native/docs/getting-started.html) page for React Native on Linux.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
For the purposes of this guide, we assume that you're working on Ubuntu Linux 14.04 LTS.
|
||||
|
||||
Before following this guide, you should have installed the Android SDK and run a successful Java-based "Hello World" app for Android.
|
||||
|
||||
See [Android Setup](/react-native/docs/android-setup.html) for details.
|
||||
|
||||
#### Installing NodeJS
|
||||
|
||||
The first thing you need to do is to install NodeJS, a popular Javascript implementation.
|
||||
|
||||
Fire up the Terminal and type the following commands to install NodeJS from the [NodeSource](https://nodesource.com/) repository:
|
||||
|
||||
```sh
|
||||
sudo apt-get install -y build-essential
|
||||
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||
```
|
||||
__NOTE__: The above instructions are for Ubuntu. If you're on a different distro, please follow the instructions on the [NodeJS website](https://nodejs.org/en/download/).
|
||||
|
||||
#### Installing Watchman
|
||||
|
||||
[watchman](https://facebook.github.io/watchman/docs/install.html) is a tool by Facebook for watching changes in the filesystem. You need to install it for better performance and avoid a node file-watching bug.
|
||||
|
||||
Type the following into your terminal to compile watchman from source and install it:
|
||||
|
||||
```sh
|
||||
sudo apt-get install -y automake python-dev
|
||||
git clone https://github.com/facebook/watchman.git
|
||||
cd watchman
|
||||
git checkout v4.5.0 # the latest stable release
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
__NOTE__: The above ```apt-get install``` line is for Ubuntu/Debian only. You might need to install required dependencies differently on other distributions.
|
||||
|
||||
#### Installing Flow
|
||||
|
||||
Flow is a static type checker for JavaScript. To install it, type the following in the terminal:
|
||||
|
||||
```sh
|
||||
npm install -g flow-bin
|
||||
```
|
||||
|
||||
## Setting up an Android Device
|
||||
|
||||
Let's set up an Android device to run our starter project.
|
||||
|
||||
First thing is to plug in your device and check the manufacturer code by using `lsusb`, which should output something like this:
|
||||
|
||||
```bash
|
||||
$ lsusb
|
||||
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 001 Device 003: ID 22b8:2e76 Motorola PCS
|
||||
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
||||
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
```
|
||||
These lines represent the USB devices currently connected to your machine.
|
||||
|
||||
You want the line that represents your phone. If you're in doubt, try unplugging your phone and running the command again:
|
||||
|
||||
```bash
|
||||
$ lsusb
|
||||
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
||||
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
```
|
||||
You'll see that after removing the phone, the line which has the phone model ("Motorola PCS" in this case) disappeared from the list. This is the line that we care about.
|
||||
|
||||
`Bus 001 Device 003: ID 22b8:2e76 Motorola PCS`
|
||||
|
||||
From the above line, you want to grab the first four digits from the device ID:
|
||||
|
||||
`22b8:2e76`
|
||||
|
||||
In this case, it's `22b8`. That's the identifier for Motorola.
|
||||
|
||||
You'll need to input this into your udev rules in order to get up and running:
|
||||
|
||||
```sh
|
||||
echo SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev" | sudo tee /etc/udev/rules.d/51-android-usb.rules
|
||||
```
|
||||
|
||||
Make sure that you replace `22b8` with the identifier you get in the above command.
|
||||
|
||||
Now check that your device is properly connecting to ADB, the Android Debug Bridge, by using `adb devices`.
|
||||
|
||||
```bash
|
||||
List of devices attached
|
||||
TA9300GLMK device
|
||||
```
|
||||
|
||||
For more information, please see the docs for [running an Android app on your device](/react-native/docs/running-on-device-android.html).
|
||||
|
||||
## Next Steps
|
||||
|
||||
Your Android device and your tools are all ready to go. You can now follow the instructions in the [Quick Start](http://facebook.github.io/react-native/docs/getting-started.html#quick-start) guide to install React Native and start your first project.
|
||||
@@ -20,7 +20,7 @@ While both environments are very similar, you may end up hitting some inconsiste
|
||||
|
||||
Syntax transformers make writing code more enjoyable by allowing you to use new JavaScript syntax without having to wait for support on all interpreters.
|
||||
|
||||
As of version 0.5.0, React Native ships with the [Babel JavaScript compiler](https://babeljs.io). Check [Babel documentation](http://babeljs.io/docs/advanced/transformers/) on its supported transformations for more details.
|
||||
As of version 0.5.0, React Native ships with the [Babel JavaScript compiler](https://babeljs.io). Check [Babel documentation](https://babeljs.io/docs/plugins/#transform-plugins) on its supported transformations for more details.
|
||||
|
||||
Here's a full list of React Native's [enabled transformations](https://github.com/facebook/react-native/blob/master/babel-preset/configs/main.js#L16).
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
id: linux-windows-support
|
||||
title: Linux and Windows Support
|
||||
layout: docs
|
||||
category: Quick Start
|
||||
permalink: docs/linux-windows-support.html
|
||||
next: tutorial
|
||||
---
|
||||
|
||||
__NOTE: This guide focuses on Android development. You'll need a Mac to build iOS apps.__
|
||||
|
||||
As React Native on iOS requires a Mac and most of the engineers at Facebook and contributors use Macs, support for OS X is a top priority. However, we would like to support developers using Linux and Windows too. We believe we'll get the best Linux and Windows support from people using these operating systems on a daily basis.
|
||||
|
||||
Therefore, Linux and Windows support for the development environment is an ongoing community responsibility. This can mean filing issues and submitting PRs, and we'll help review and merge them. We are looking forward to your contributions and appreciate your patience.
|
||||
|
||||
As of **version 0.14** Android development with React native is mostly possible on Linux and Windows. You'll need to install [Node.js](https://nodejs.org/) 4.0 or newer. On Linux we recommend installing [watchman](https://facebook.github.io/watchman/docs/install.html), otherwise you might hit a node file watching bug.
|
||||
|
||||
## What's missing on Windows
|
||||
|
||||
On Windows the packager won't be started automatically when you run `react-native run-android`. You can start it manually using:
|
||||
|
||||
cd MyAwesomeApp
|
||||
react-native start
|
||||
|
||||
If you hit a `ERROR Watcher took too long to load` on Windows, try increasing the timeout in [this file](https://github.com/facebook/react-native/blob/5fa33f3d07f8595a188f6fe04d6168a6ede1e721/packager/react-packager/src/DependencyResolver/FileWatcher/index.js#L16) (under your `node_modules/react-native/`).
|
||||
|
||||
|
||||
@@ -22,6 +22,60 @@ Seeing **device** in the right column means the device is connected. Android - g
|
||||
|
||||
Now you can use `react-native run-android` to install and launch your app on the device.
|
||||
|
||||
## Setting up an Android Device
|
||||
|
||||
Let's now set up an Android device to run our React Native projects.
|
||||
|
||||
First thing is to plug in your device and check the manufacturer code by using `lsusb`, which should output something like this:
|
||||
|
||||
```bash
|
||||
$ lsusb
|
||||
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 001 Device 003: ID 22b8:2e76 Motorola PCS
|
||||
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
||||
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
```
|
||||
These lines represent the USB devices currently connected to your machine.
|
||||
|
||||
You want the line that represents your phone. If you're in doubt, try unplugging your phone and running the command again:
|
||||
|
||||
```bash
|
||||
$ lsusb
|
||||
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|
||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
|
||||
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
```
|
||||
You'll see that after removing the phone, the line which has the phone model ("Motorola PCS" in this case) disappeared from the list. This is the line that we care about.
|
||||
|
||||
`Bus 001 Device 003: ID 22b8:2e76 Motorola PCS`
|
||||
|
||||
From the above line, you want to grab the first four digits from the device ID:
|
||||
|
||||
`22b8:2e76`
|
||||
|
||||
In this case, it's `22b8`. That's the identifier for Motorola.
|
||||
|
||||
You'll need to input this into your udev rules in order to get up and running:
|
||||
|
||||
```sh
|
||||
echo SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev" | sudo tee /etc/udev/rules.d/51-android-usb.rules
|
||||
```
|
||||
|
||||
Make sure that you replace `22b8` with the identifier you get in the above command.
|
||||
|
||||
Now check that your device is properly connecting to ADB, the Android Debug Bridge, by using `adb devices`.
|
||||
|
||||
```bash
|
||||
List of devices attached
|
||||
TA9300GLMK device
|
||||
```
|
||||
|
||||
## Accessing development server from device
|
||||
|
||||
You can also iterate quickly on device using the development server. Follow one of the steps described below to make your development server running on your laptop accessible for your device.
|
||||
|
||||
@@ -57,6 +57,17 @@ module.exports = function upgrade(args, config) {
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (semver.satisfies(v, '~0.26.0')) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n' +
|
||||
'perform them manually by checking the release notes or use \'rnpm\' to do it automatically.\n' +
|
||||
'Just run:\n' +
|
||||
'\'npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev\', then run \'rnpm upgrade\''
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native",
|
||||
"version": "1000.0.0",
|
||||
"version": "0.26.0",
|
||||
"description": "A framework for building native apps using React",
|
||||
"license": "BSD-3-Clause",
|
||||
"repository": {
|
||||
@@ -190,4 +190,4 @@
|
||||
"react": "15.0.2",
|
||||
"shelljs": "0.6.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,12 +60,17 @@ if (buildBranch.indexOf(`-stable`) !== -1) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ['latest', 'v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2', 'v0.34.0', '']
|
||||
const tagsWithVersion = exec(`git tag -l --points-at HEAD`).stdout.split(/\s/)
|
||||
// ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2', 'v0.34.0']
|
||||
.filter(version => !!version && version.indexOf(`v${branchVersion}`) === 0)
|
||||
// 34c034298dc9cad5a4553964a5a324450fda0385
|
||||
const currentCommit = exec(`git rev-parse HEAD`, {silent: true}).stdout.trim();
|
||||
// [34c034298dc9cad5a4553964a5a324450fda0385, refs/heads/0.33-stable, refs/tags/latest, refs/tags/v0.33.1, refs/tags/v0.34.1-rc]
|
||||
const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {silent: true})
|
||||
.stdout.split(/\s/)
|
||||
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2', 'refs/tags/v0.34.0']
|
||||
.filter(version => !!version && version.indexOf(`refs/tags/v${branchVersion}`) === 0)
|
||||
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2']
|
||||
.filter(version => version.indexOf(branchVersion) !== -1)
|
||||
// ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2']
|
||||
.filter(version => version.indexOf(branchVersion) !== -1);
|
||||
.map(version => version.slice(`refs/tags/`.length));
|
||||
|
||||
if (tagsWithVersion.length === 0) {
|
||||
echo(`Error: Can't find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit`);
|
||||
|
||||
@@ -221,11 +221,11 @@ try {
|
||||
exitCode = 1;
|
||||
throw Error(exitCode);
|
||||
}
|
||||
if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
|
||||
echo('Flow check does not pass');
|
||||
exitCode = 1;
|
||||
throw Error(exitCode);
|
||||
}
|
||||
// if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
|
||||
// echo('Flow check does not pass');
|
||||
// exitCode = 1;
|
||||
// throw Error(exitCode);
|
||||
// }
|
||||
}
|
||||
exitCode = 0;
|
||||
|
||||
|
||||
@@ -544,25 +544,39 @@ var Autodocs = React.createClass({
|
||||
);
|
||||
},
|
||||
|
||||
renderExample: function(docs, metadata) {
|
||||
if (!docs.example) {
|
||||
renderExample: function(example, metadata) {
|
||||
if (!example) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<HeaderWithGithub
|
||||
title="Examples"
|
||||
path={docs.example.path}
|
||||
title={example.title || 'Examples'}
|
||||
level={example.title ? 4 : 3}
|
||||
path={example.path}
|
||||
metadata={metadata}
|
||||
/>
|
||||
<Prism>
|
||||
{docs.example.content.replace(/^[\s\S]*?\*\//, '').trim()}
|
||||
{example.content.replace(/^[\s\S]*?\*\//, '').trim()}
|
||||
</Prism>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
renderExamples: function(docs, metadata) {
|
||||
if (!docs.examples || !docs.examples.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{(docs.examples.length > 1) ? <H level={3}>Examples</H> : null}
|
||||
{docs.examples.map(example => this.renderExample(example, metadata))}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var metadata = this.props.metadata;
|
||||
var docs = JSON.parse(this.props.children);
|
||||
@@ -583,7 +597,7 @@ var Autodocs = React.createClass({
|
||||
/>
|
||||
{content}
|
||||
{this.renderFullDescription(docs)}
|
||||
{this.renderExample(docs, metadata)}
|
||||
{this.renderExamples(docs, metadata)}
|
||||
<div className="docs-prevnext">
|
||||
{metadata.previous && <a className="docs-prev" href={'docs/' + metadata.previous + '.html#content'}>← Prev</a>}
|
||||
{metadata.next && <a className="docs-next" href={'docs/' + metadata.next + '.html#content'}>Next →</a>}
|
||||
|
||||
@@ -43,6 +43,15 @@ var DocsLayout = React.createClass({
|
||||
{metadata.previous && <a className="docs-prev" href={'docs/' + metadata.previous + '.html#content'}>← Prev</a>}
|
||||
{metadata.next && <a className="docs-next" href={'docs/' + metadata.next + '.html#content'}>Next →</a>}
|
||||
</div>
|
||||
<div className="survey">
|
||||
<div className="survey-image" />
|
||||
<p>
|
||||
We are planning improvements to the React Native documentation. Your responses to this short survey will go a long way in helping us provide valuable content. Thank you!
|
||||
</p>
|
||||
<center>
|
||||
<a className="button" href="https://www.facebook.com/survey?oid=681969738611332">Take Survey</a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Site>
|
||||
|
||||
@@ -57,18 +57,48 @@ function getPlatformFromPath(filepath) {
|
||||
return CROSS_SUFFIX;
|
||||
}
|
||||
|
||||
function getExample(componentName, componentPlatform) {
|
||||
let exPath = '../Examples/UIExplorer/' + componentName + 'Example.js';
|
||||
if (!fs.existsSync(exPath)) {
|
||||
exPath = '../Examples/UIExplorer/' + componentName + 'Example.' + componentPlatform + '.js';
|
||||
if (!fs.existsSync(exPath)) {
|
||||
return;
|
||||
}
|
||||
function getExamplePaths(componentName, componentPlatform) {
|
||||
var componentExample = '../Examples/UIExplorer/' + componentName + 'Example.';
|
||||
var pathsToCheck = [
|
||||
componentExample + 'js',
|
||||
componentExample + componentPlatform + '.js',
|
||||
];
|
||||
if (componentPlatform === CROSS_SUFFIX) {
|
||||
pathsToCheck.push(
|
||||
componentExample + IOS_SUFFIX + '.js',
|
||||
componentExample + ANDROID_SUFFIX + '.js'
|
||||
);
|
||||
}
|
||||
return {
|
||||
path: exPath.replace(/^\.\.\//, ''),
|
||||
content: fs.readFileSync(exPath).toString(),
|
||||
};
|
||||
var paths = [];
|
||||
pathsToCheck.map((p) => {
|
||||
if (fs.existsSync(p)) {
|
||||
paths.push(p);
|
||||
}
|
||||
});
|
||||
return paths;
|
||||
}
|
||||
|
||||
function getExamples(componentName, componentPlatform) {
|
||||
var paths = getExamplePaths(componentName, componentPlatform);
|
||||
if (paths) {
|
||||
var examples = [];
|
||||
paths.map((p) => {
|
||||
var platform = p.match(/Example\.(.*)\.js$/);
|
||||
var title = '';
|
||||
if ((componentPlatform === CROSS_SUFFIX) && (platform !== null)) {
|
||||
title = platform[1].toUpperCase();
|
||||
}
|
||||
examples.push(
|
||||
{
|
||||
path: p.replace(/^\.\.\//, ''),
|
||||
title: title,
|
||||
content: fs.readFileSync(p).toString(),
|
||||
}
|
||||
);
|
||||
});
|
||||
return examples;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Add methods that should not appear in the components documentation.
|
||||
@@ -98,14 +128,12 @@ function filterMethods(method) {
|
||||
// Determines whether a component should have a link to a runnable example
|
||||
|
||||
function isRunnable(componentName, componentPlatform) {
|
||||
let exPath = '../Examples/UIExplorer/' + componentName + 'Example.js';
|
||||
if (!fs.existsSync(exPath)) {
|
||||
exPath = '../Examples/UIExplorer/' + componentName + 'Example.' + componentPlatform + '.js';
|
||||
if (!fs.existsSync(exPath)) {
|
||||
return false;
|
||||
}
|
||||
var paths = getExamplePaths(componentName, componentPlatform);
|
||||
if (paths && paths.length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hide a component from the sidebar by making it return false from
|
||||
@@ -148,7 +176,7 @@ function componentsToMarkdown(type, json, filepath, idx, styles) {
|
||||
if (styles) {
|
||||
json.styles = styles;
|
||||
}
|
||||
json.example = getExample(componentName, componentPlatform);
|
||||
json.examples = getExamples(componentName, componentPlatform);
|
||||
|
||||
if (json.methods) {
|
||||
json.methods = json.methods.filter(filterMethods);
|
||||
|
||||
@@ -38,7 +38,7 @@ h1 small, h2 small, h3 small, h4 small, h5 small, h6 small {
|
||||
color: #7b7b7b;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
h1, h2, h3, h4 {
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
@@ -683,8 +683,7 @@ h2 {
|
||||
}
|
||||
|
||||
.documentationContent blockquote p:first-child {
|
||||
font-weight: bold;
|
||||
font-size: 17.5px;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
margin-top: 0;
|
||||
text-rendering: optimizelegibility;
|
||||
@@ -1257,12 +1256,48 @@ div[data-twttr-id] iframe {
|
||||
background-color: hsl(198, 100%, 94%);
|
||||
}
|
||||
|
||||
.survey {
|
||||
padding: 10px;
|
||||
padding-top: 0;
|
||||
background-color: rgba(5, 165, 209, 0.05);
|
||||
border: 2px solid #05A5D1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.survey-image {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
height: 83px;
|
||||
width: 120px;
|
||||
background-image: url('../img/survey.png');
|
||||
background-size: 272px 198px;
|
||||
background-position: -8px -8px;
|
||||
}
|
||||
|
||||
.survey p {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.survey .button {
|
||||
font-size: 24px;
|
||||
background: #05A5D1;
|
||||
color: #fafafa;
|
||||
}
|
||||
|
||||
@media only screen
|
||||
and (max-device-width: 1024px) {
|
||||
#content {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.survey-image {
|
||||
position: static;
|
||||
margin: 10px auto;
|
||||
}
|
||||
.survey p {
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.container {
|
||||
min-width: 0;
|
||||
overflow: auto;
|
||||
|
||||
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 405 KiB |
|
After Width: | Height: | Size: 234 KiB |
|
After Width: | Height: | Size: 225 KiB |
|
After Width: | Height: | Size: 403 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 190 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 129 KiB |