Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Libraries/Geolocation/Geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ type GeoOptions = {
* As a browser polyfill, this API is available through the `navigator.geolocation`
* global - you do not need to `import` it.
*
* ### iOS
* ### Configuration and Permissions
*
* <div class="banner-crna-ejected">
* <h3>Native Builds Only</h3>
* <p>
* This section only applies to apps made with <code>react-native init</code>
* or to those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* #### iOS
* You need to include the `NSLocationWhenInUseUsageDescription` key
* in Info.plist to enable geolocation when using the app. Geolocation is
* enabled by default when you create a project with `react-native init`.
Expand All @@ -46,7 +59,7 @@ type GeoOptions = {
* 'NSLocationAlwaysUsageDescription' key in Info.plist and add location as
* a background mode in the 'Capabilities' tab in Xcode.
*
* ### Android
* #### Android
* To request access to location, you need to add the following line to your
* app's `AndroidManifest.xml`:
*
Expand Down
11 changes: 11 additions & 0 deletions Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ const LinkingManager = Platform.OS === 'android' ?
NativeModules.IntentAndroid : NativeModules.LinkingManager;

/**
* <div class="banner-crna-ejected">
* <h3>Native Builds Only</h3>
* <p>
* This API only works in apps made with <code>react-native init</code>
* or in those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* `Linking` gives you a general interface to interact with both incoming
* and outgoing app links.
*
Expand Down
12 changes: 11 additions & 1 deletion Libraries/PermissionsAndroid/PermissionsAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ type Rationale = {
}

type PermissionStatus = 'granted' | 'denied' | 'never_ask_again';

/**
* <div class="banner-crna-ejected">
* <h3>Native Builds Only</h3>
* <p>
* This API only works in apps made with <code>react-native init</code>
* or in those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* `PermissionsAndroid` provides access to Android M's new permissions model.
* Some permissions are granted by default when the application is installed
* so long as they appear in `AndroidManifest.xml`. However, "dangerous"
Expand Down
13 changes: 12 additions & 1 deletion Libraries/PushNotificationIOS/PushNotificationIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,22 @@ export type PushNotificationEventName = $Enum<{
}>;

/**
* <div class="banner-crna-ejected">
* <h3>Native Builds Only</h3>
* <p>
* This API only works in apps made with <code>react-native init</code>
* or in those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* Handle push notifications for your app, including permission handling and
* icon badge number.
*
* To get up and running, [configure your notifications with Apple](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW6)
* and your server-side system. To get an idea, [this is the Parse guide](https://parse.com/tutorials/ios-push-notifications).
* and your server-side system.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me pours one out for Parse.

*
* [Manually link](docs/linking-libraries-ios.html#manual-linking) the PushNotificationIOS library
*
Expand Down
11 changes: 11 additions & 0 deletions Libraries/ReactNative/AppRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook =
(component: ComponentProvider) => component();

/**
* <div class="banner-crna-ejected">
* <h3>Native Builds Only</h3>
* <p>
* This API only works in apps made with <code>react-native init</code>
* or in those made with Create React Native App which have since ejected. For
* more information about ejecting, please see
* the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
* the Create React Native App repository.
* </p>
* </div>
*
* `AppRegistry` is the JS entry point to running all React Native apps. App
* root components should register themselves with
* `AppRegistry.registerComponent`, then the native system can load the bundle
Expand Down
59 changes: 39 additions & 20 deletions docs/Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,45 @@ In CI/Xcode, YellowBoxes can also be disabled by setting the `IS_TESTING` enviro

> RedBoxes and YellowBoxes are automatically disabled in release (production) builds.

## Chrome Developer Tools

To debug the JavaScript code in Chrome, select "Debug JS Remotely" from the Developer Menu. This will open a new tab at [http://localhost:8081/debugger-ui](http://localhost:8081/debugger-ui).

Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (**`Command`**`⌘` + **`Option`**`⌥` + **`I`** on Mac, **`Ctrl`** + **`Shift`** + **`I`** on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.

> It is [currently not possible](https://github.com/facebook/react-devtools/issues/229) to use the "React" tab in the Chrome Developer Tools to inspect app widgets. You can use Nuclide's "React Native Inspector" as a workaround.

### Debugging using a custom JavaScript debugger

To use a custom JavaScript debugger in place of Chrome Developer Tools, set the `REACT_DEBUGGER` environment variable to a command that will start your custom debugger. You can then select "Debug JS Remotely" from the Developer Menu to start debugging.

The debugger will receive a list of all project roots, separated by a space. For example, if you set `REACT_DEBUGGER="node /path/to/launchDebugger.js --port 2345 --type ReactNative"`, then the command `node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app` will be used to start your debugger.

> Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.

## Performance Monitor

You can enable a performance overlay to help you debug performance problems by selecting "Perf Monitor" in the Developer Menu.

<hr style="margin-top:25px; margin-bottom:25px;"/>

# Debugging in Ejected Apps

<div class="banner-crna-ejected" style="margin-top:25px">
<h3>Native Builds Only</h3>
<p>
The remainder of this guide only applies to apps made with <code>react-native init</code>
or to those made with Create React Native App which have since ejected. For
more information about ejecting, please see
the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on
the Create React Native App repository.
</p>
</div>

## Accessing console logs

Note: if you're using Create React Native App, these already appear in the same terminal output as the packager.

You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:

```
Expand All @@ -68,15 +105,9 @@ $ react-native log-android

You may also access these through `Debug → Open System Log...` in the iOS Simulator or by running `adb logcat *:S ReactNative:V ReactNativeJS:V` in a terminal while an Android app is running on a device or emulator.

## Chrome Developer Tools

To debug the JavaScript code in Chrome, select "Debug JS Remotely" from the Developer Menu. This will open a new tab at [http://localhost:8081/debugger-ui](http://localhost:8081/debugger-ui).
## Debugging on a device with Chrome Developer Tools

Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (**`Command`**`⌘` + **`Option`**`⌥` + **`I`** on Mac, **`Ctrl`** + **`Shift`** + **`I`** on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.

> It is [currently not possible](https://github.com/facebook/react-devtools/issues/229) to use the "React" tab in the Chrome Developer Tools to inspect app widgets. You can use Nuclide's "React Native Inspector" as a workaround.

### Debugging on a device with Chrome Developer Tools
Note: if you're using Create React Native App, this is configured for you already.

On iOS devices, open the file [`RCTWebSocketExecutor.m`](https://github.com/facebook/react-native/blob/master/Libraries/WebSocket/RCTWebSocketExecutor.m) and change "localhost" to the IP address of your computer, then select "Debug JS Remotely" from the Developer Menu.

Expand All @@ -88,14 +119,6 @@ Alternatively, select "Dev Settings" from the Developer Menu, then update the "D

> If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.

### Debugging using a custom JavaScript debugger

To use a custom JavaScript debugger in place of Chrome Developer Tools, set the `REACT_DEBUGGER` environment variable to a command that will start your custom debugger. You can then select "Debug JS Remotely" from the Developer Menu to start debugging.

The debugger will receive a list of all project roots, separated by a space. For example, if you set `REACT_DEBUGGER="node /path/to/launchDebugger.js --port 2345 --type ReactNative"`, then the command `node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app` will be used to start your debugger.

> Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.

### Debugging with [Stetho](http://facebook.github.io/stetho/) on Android

1. In ```android/app/build.gradle```, add these lines in the `dependencies` section:
Expand Down Expand Up @@ -139,7 +162,3 @@ The debugger will receive a list of all project roots, separated by a space. For
## Debugging native code

When working with native code (e.g. when writing native modules) you can launch the app from Android Studio or Xcode and take advantage of the debugging features (setup breakpoints, etc.) as you would in case of building a standard native app.

## Performance Monitor

You can enable a performance overlay to help you debug performance problems by selecting "Perf Monitor" in the Developer Menu.
36 changes: 34 additions & 2 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,40 @@ your system, so that you can build apps with it right away. If you already
have React Native installed, you can skip ahead to the
[Tutorial](docs/tutorial.html).

The instructions are a bit different depending on your development operating system, and whether you want to start developing for iOS or Android. If you
want to develop for both iOS and Android, that's fine - you just have to pick
## Quick Start

[Create React Native App](https://github.com/react-community/create-react-native-app) is the easiest way to start building a new React Native application. It allows you to start a project without installing or configuring any native build tools.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing is meant to mirror Create React App's in the React docs, but is fungible as far as I'm concerned.


Assuming that you have Node installed, no Xcode or Android Studio installation is required:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically CRNA supports Node 6 or higher, not sure it's worth specifying here due to risk of bitrot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrasing here seems a bit odd to me (but keep in mind, English is my second language). The way I read it, Xcode or Android Studio may be required if I don't have Node installed.
Maybe we can split into two sentences, and swap the order? Something like:

No Xcode or Android Studio installation is required. Assuming that you have Node installed, you can run the following commands to create a new React Native projected called "AwesomeProject":

I'm mirroring the instructions for Native Builds at the end here, "AwesomeProject" could be anything but ideally it would match the original RN init commands.

After this PR gets merged I'll probably take another pass at updating the Getting Started guide and subsequent pages, as I'd like to update the tutorial so that it builds on top of the CRNA started project similar to what we did at F8 this year.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point -- writing for ESL audiences is not my strength.


```
npm install -g create-react-native-app
create-react-native-app hello-world

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this and the next line to AwesomeApp (or update the instructions for RN init to use "hello-world", too)

cd hello-world
npm start
```

This will start a development server for you, and print a QR code in your terminal.

Install the [Expo](https://expo.io) client app on your iOS or Android phone, make sure your phone is on the same network as your computer, and scan the QR code in your terminal to open your project. The QR scanner is available under the "Projects" tab of the app. Create React Native App also has a [user guide](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md) you can reference if you have questions specific to the tool.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leave out "The QR scanner is available under the Projects tab of the app". When I launch the Expo app, the Projects tab is visible by default and I can see a "Scan QR Code" callout at the top so it seems people can figure this out.

I don't feel too strongly about this though, if for example you've found that Expo users tend to be confused by this bit then we can leave this in.


Once you've created your project and opened it in the Expo client app, you can proceed to the [Tutorial](docs/tutorial.html).

### Caveats

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having this as a subsection makes sense because we want to surface the information for advanced users (read: the ones who are willing to read more than 3 sentences due to existing investment) early on without muddying the waters for really new people.

Very open to suggestions on the structure of this though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd have a standalone CRNA doc that covers any caveats, as well as the ejection process. We can tackle that in a different PR though, I'm OK with this section here for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a note to follow up with you on that after you're back.


Because you don't build any native code with Create React Native App, it's not possible to include custom native modules beyond the React Native APIs and components that are available in the Expo client app.

@anp anp Apr 4, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this includes the Expo SDK as well, but there's a tradeoff here:

  • don't want to have to educate new users too much about all of these distinctions
  • users may not use CRNA if they believe that there's not enough in the client to experiment with

I think it's OK to favor the former over the latter, myself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, once we have a CRNA doc we can be more verbose there.


If you know that you'll eventually need to include your own native code, Create React Native App is still a good way to get started. In that case you'll just need to "[eject](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md#ejecting-from-create-react-native-app)" eventually to create your own native builds. If you do eject, the native build instructions below will be required to continue working on your project.

If you're integrating React Native into an existing project, you'll want to skip Create React Native App and go directly to setting up the native build environment. See below for instructions on configuring a native build environment for React Native.

<hr style="margin-top:25px"/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

halp i'm trapped in 1999 and can't get out


## Native Builds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this section title yet but I don't have a better suggestion just yet shrug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatives I see right off the bat:

  • Building with Xcode and Android Studio
  • Custom Build Environment
  • Building with Custom Native Code
  • Building Your Own Native Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking about this and have currently landed on these two terms to distinguish between the two types of React Native projects people might be working with:

  • Create-React-Native-App Projects
  • Projects with Native Code

The second one covers any project created using react-native init, or using CRNA but has since "ejected".

If we use these terms, then this section could be named "Building Projects with Native Code". Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯


Follow these instructions if you need your own native build configuration. For example, if you "ejected" from Create React Native app, or if you are integrating React Native into an existing application, you'll need this section.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain that, if you "ejected" or are integrating into an existing app, you will need to setup all the dependencies covered in this section. The idea would be to make it clear RN init is not necessary (as you already have a project). To me it's obvious RN init is not needed, but it may not be clear to a new user if RN init does some additional, required setup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point. What do you think about making the example commands something like this?

# skip this first command if you ejected from Create React Native App
react-native init AwesomeProject
cd AwesomeProject
react-native run-ios

I think that's the most likely place for users to see it, but it might be better to have a more thorough explanation elsewhere? Doing both might be too much given the limited real estate, but I'm very open to suggestions here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I pushed up a commit that implements the example I previously commented, let me know if you think it's too clunky or should be moved to a central location?


The instructions are a bit different depending on your development operating system, and whether you want to start developing for iOS or Android. If you want to develop for both iOS and Android, that's fine - you just have to pick
one to start with, since the setup is a bit different.

<div class="toggler">
Expand Down
2 changes: 0 additions & 2 deletions docs/MoreResources.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ The folks who built the app for Facebook's F8 conference in 2016 also [open-sour

[Nuclide](https://nuclide.io/) is the IDE that Facebook uses internally for React Native development. The killer feature of Nuclide is its debugging ability. It also has great inline Flow support.

[Create React Native App](https://github.com/react-community/create-react-native-app) makes it significantly easier to get started with a React Native project. There's no need to use Xcode or Android Studio, and you can develop for your iOS device using Linux or Windows.

[Ignite](https://github.com/infinitered/ignite) is a starter kit that uses Redux and a few different common UI libraries. It has a CLI to generate apps, components, and containers. If you like all of the individual tech choices, Ignite could be perfect for you.

[CodePush](https://microsoft.github.io/code-push/) is a service from Microsoft that makes it easy to deploy live updates to your React Native app. If you don't like going through the app store process to deploy little tweaks, and you also don't like setting up your own backend, give CodePush a try.
Expand Down
30 changes: 30 additions & 0 deletions website/core/EjectBanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule EjectBanner
*/
'use strict';

var React = require('React');

var EjectBanner = React.createClass({
render: function() {
return (
<div className="banner-crna-ejected">
<h3>Native Build Required</h3>
<p>
This page only applies to apps made with <code>react-native init</code> or to those made
with Create React Native App which have since ejected. For more information about ejecting,
please see the <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" target="_blank">guide</a> on the Create React Native App repository.
</p>
</div>
);
}
});

module.exports = EjectBanner;
2 changes: 2 additions & 0 deletions website/layout/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'use strict';

var DocsSidebar = require('DocsSidebar');
var EjectBanner = require('EjectBanner');
var Footer = require('Footer');
var Header = require('Header');
var Marked = require('Marked');
Expand Down Expand Up @@ -43,6 +44,7 @@ var DocsLayout = React.createClass({
<div className="inner-content">
<a id="content" />
<Header level={1}>{metadata.title}</Header>
{(metadata.banner === 'ejected') ? <EjectBanner/> : null}
<Marked>{content}</Marked>
<div className="docs-prevnext">
{metadata.previous && <a className="docs-prev" href={'docs/' + metadata.previous + '.html#content'}>&larr; Prev</a>}
Expand Down