diff --git a/docs/accessibility.html b/docs/accessibility.html index 4a5fb05cdf4..a03472b83ef 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,4 +1,4 @@ -Accessibility – React Native | A framework for building native apps using React

Accessibility #

Edit on GitHub

Native App Accessibility (iOS and Android) #

Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.

On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.

<View accessible={true}> +Accessibility – React Native | A framework for building native apps using React

Accessibility #

Edit on GitHub

Native App Accessibility (iOS and Android) #

Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.

On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.

<View accessible={true}> <Text>text one</Text> <Text>text two</Text> </View>

In the above example, we can't get accessibility focus separately on 'text one' and 'text two'. Instead we get focus on a parent view with 'accessible' property.

accessibilityLabel (iOS, Android) #

When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.

To use, set the accessibilityLabel property to a custom string on your View:

<TouchableOpacity accessible={true} accessibilityLabel={'Tap me!'} onPress={this._onPress}> @@ -31,7 +31,7 @@ “radiobutton_unchecked” : “radiobutton_checked”; if (this.state.radioButton === “radiobutton_checked”) { RCTUIManager.sendAccessibilityEvent( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), RCTUIManager.AccessibilityEventTypes.typeViewClicked); } } @@ -54,6 +54,6 @@ apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/actionsheetios.html b/docs/actionsheetios.html index 3874dc91d27..2c431403b04 100644 --- a/docs/actionsheetios.html +++ b/docs/actionsheetios.html @@ -1,17 +1,18 @@ -ActionSheetIOS – React Native | A framework for building native apps using React

ActionSheetIOS #

Edit on GitHub

Methods #

static showActionSheetWithOptions(options: Object, callback: Function) #

Display an iOS action sheet. The options object must contain one or more -of:

  • options (array of strings) - a list of button titles (required)
  • cancelButtonIndex (int) - index of cancel button in options
  • destructiveButtonIndex (int) - index of destructive button in options
  • title (string) - a title to show above the action sheet
  • message (string) - a message to show below the title

static showShareActionSheetWithOptions(options: Object, failureCallback: Function, successCallback: Function) #

Display the iOS share sheet. The options object should contain +ActionSheetIOS – React Native | A framework for building native apps using React

ActionSheetIOS #

Edit on GitHub

Methods #

static showActionSheetWithOptions(options, callback) #

Display an iOS action sheet. The options object must contain one or more +of:

  • options (array of strings) - a list of button titles (required)
  • cancelButtonIndex (int) - index of cancel button in options
  • destructiveButtonIndex (int) - index of destructive button in options
  • title (string) - a title to show above the action sheet
  • message (string) - a message to show below the title

static showShareActionSheetWithOptions(options, failureCallback, successCallback) #

Display the iOS share sheet. The options object should contain one or both of:

  • message (string) - a message to share
  • url (string) - a URL to share

NOTE: if url points to a local file, or is a base64-encoded uri, the file it points to will be loaded and shared directly. In this way, you can share images, videos, PDF files, etc.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { ActionSheetIOS, StyleSheet, Text, UIManager, View, -} = React; +} = ReactNative; var BUTTONS = [ 'Option 0', @@ -226,6 +227,6 @@ exports.examples \ No newline at end of file diff --git a/docs/activityindicatorios.html b/docs/activityindicatorios.html index 6493cce7aad..4948f479901 100644 --- a/docs/activityindicatorios.html +++ b/docs/activityindicatorios.html @@ -1,11 +1,12 @@ -ActivityIndicatorIOS – React Native | A framework for building native apps using React

ActivityIndicatorIOS #

Edit on GitHub

Props #

animating bool #

Whether to show the indicator (true, the default) or hide it (false).

color string #

The foreground color of the spinner (default is gray).

hidesWhenStopped bool #

Whether the indicator should hide when not animating (true by default).

onLayout function #

Invoked on mount and layout changes with

{nativeEvent: { layout: {x, y, width, height}}}.

size enum('small', 'large') #

Size of the indicator. Small has a height of 20, large has a height of 36.

Examples #

Edit on GitHub
'use strict'; +ActivityIndicatorIOS – React Native | A framework for building native apps using React

ActivityIndicatorIOS #

Edit on GitHub

Props #

animating bool #

Whether to show the indicator (true, the default) or hide it (false).

color string #

The foreground color of the spinner (default is gray).

hidesWhenStopped bool #

Whether the indicator should hide when not animating (true by default).

onLayout function #

Invoked on mount and layout changes with

{nativeEvent: { layout: {x, y, width, height}}}.

size enum('small', 'large') #

Size of the indicator. Small has a height of 20, large has a height of 36.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { ActivityIndicatorIOS, StyleSheet, View, -} = React; +} = ReactNative; var TimerMixin = require('react-timer-mixin'); var ToggleAnimatingActivityIndicator = React.createClass({ @@ -160,6 +161,6 @@ exports.examples \ No newline at end of file diff --git a/docs/alert.html b/docs/alert.html index 0e29dfc4dcc..d2c47354ea1 100644 --- a/docs/alert.html +++ b/docs/alert.html @@ -1,4 +1,4 @@ -Alert – React Native | A framework for building native apps using React

Alert #

Edit on GitHub

Launches an alert dialog with the specified title and message.

Optionally provide a list of buttons. Tapping any button will fire the +Alert – React Native | A framework for building native apps using React

Alert #

Edit on GitHub

Launches an alert dialog with the specified title and message.

Optionally provide a list of buttons. Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button.

This is an API that works both on iOS and Android and can show static alerts. To show an alert that prompts the user to enter some information, @@ -13,16 +13,17 @@ of a neutral, negative and a positive button:

  • If you specify one butt {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, {text: 'OK', onPress: () => console.log('OK Pressed')}, ] -)

Methods #

static alert(title: string, message?: string, buttons?: Buttons, type?: AlertType) #

Examples #

Edit on GitHub
'use strict'; +)

Methods #

static alert(title, message?, buttons?, type?) #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Alert, StyleSheet, Text, TouchableHighlight, View, -} = React; +} = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); @@ -149,6 +150,6 @@ module.exports \ No newline at end of file diff --git a/docs/alertios.html b/docs/alertios.html index f6309a3cc9f..bd284ed723b 100644 --- a/docs/alertios.html +++ b/docs/alertios.html @@ -1,8 +1,8 @@ -AlertIOS – React Native | A framework for building native apps using React

AlertIOS #

Edit on GitHub

The AlertsIOS utility provides two functions: alert and prompt. All +AlertIOS – React Native | A framework for building native apps using React

AlertIOS #

Edit on GitHub

The AlertsIOS utility provides two functions: alert and prompt. All functionality available through AlertIOS.alert is also available in the cross-platform Alert.alert, which we recommend you use if you don't need iOS-specific functionality.

AlertIOS.prompt allows you to prompt the user for input inside of an -alert popup.

Methods #

static alert(title: string, message?: string, callbackOrButtons?: ?(() => void) | ButtonsArray, type?: AlertType) #

Creates a popup to alert the user. See +alert popup.

Methods #

static alert(title, message?, callbackOrButtons?, type?) #

Creates a popup to alert the user. See Alert.

  • title: string -- The dialog's title.
  • message: string -- An optional message that appears above the text input.
  • callbackOrButtons -- This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called when the user taps 'OK'.

    If passed an array of button configurations, each button should include @@ -10,7 +10,7 @@ a text key, as well as optional onPress and styl style should be one of 'default', 'cancel' or 'destructive'.

  • type -- deprecated, do not use

Example:

AlertIOS.alert( 'Sync Complete', 'All your data are belong to us.' -);

static prompt(title: string, message?: string, callbackOrButtons?: ?((text: string) => void) | ButtonsArray, type?: AlertType, defaultValue?: string) #

Prompt the user to enter some text.

  • title: string -- The dialog's title.
  • message: string -- An optional message that appears above the text input.
  • callbackOrButtons -- This optional argument should be either a +);

static prompt(title, message?, callbackOrButtons?, type?, defaultValue?) #

Prompt the user to enter some text.

  • title: string -- The dialog's title.
  • message: string -- An optional message that appears above the text input.
  • callbackOrButtons -- This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called with the prompt's value when the user taps 'OK'.

    If passed an array of button configurations, each button should include a text key, as well as optional onPress and style keys (see example). @@ -31,14 +31,15 @@ a text key, as well as optional onPress and styl 'default' )

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, View, Text, TouchableHighlight, AlertIOS, -} = React; +} = ReactNative; var { SimpleAlertExampleBlock } = require('./AlertExample'); @@ -207,6 +208,6 @@ class PromptOptions extends \ No newline at end of file diff --git a/docs/android-building-from-source.html b/docs/android-building-from-source.html index 9ed2b0a6141..8559451c9a3 100644 --- a/docs/android-building-from-source.html +++ b/docs/android-building-from-source.html @@ -1,4 +1,4 @@ -Building React Native from source – React Native | A framework for building native apps using React

Building React Native from source #

Edit on GitHub

You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.

Prerequisites #

Assuming you have the Android SDK installed, run android to open the Android SDK Manager.

Make sure you have the following installed:

  1. Android SDK version 23 (compileSdkVersion in build.gradle)
  2. SDK build tools version 23.0.1 (buildToolsVersion in build.gradle)
  3. Android Support Repository >= 17 (for Android Support Library)
  4. Android NDK (download links and installation instructions below)

Point Gradle to your Android SDK: either have $ANDROID_SDK and $ANDROID_NDK defined, or create a local.properties file in the root of your react-native checkout with the following contents:

sdk.dir=absolute_path_to_android_sdk +Building React Native from source – React Native | A framework for building native apps using React

Building React Native from source #

Edit on GitHub

You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.

Prerequisites #

Assuming you have the Android SDK installed, run android to open the Android SDK Manager.

Make sure you have the following installed:

  1. Android SDK version 23 (compileSdkVersion in build.gradle)
  2. SDK build tools version 23.0.1 (buildToolsVersion in build.gradle)
  3. Android Support Repository >= 17 (for Android Support Library)
  4. Android NDK (download links and installation instructions below)

Point Gradle to your Android SDK: either have $ANDROID_SDK and $ANDROID_NDK defined, or create a local.properties file in the root of your react-native checkout with the following contents:

sdk.dir=absolute_path_to_android_sdk ndk.dir=absolute_path_to_android_ndk

Example:

sdk.dir=/Users/your_unix_name/android-sdk-macosx ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e

Download links for Android NDK #

  1. Mac OS (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-darwin-x86_64.zip
  2. Linux (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip
  3. Windows (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-windows-x86_64.zip
  4. Windows (32-bit) - http://dl.google.com/android/repository/android-ndk-r10e-windows-x86.zip

You can find further instructions on the official page.

Building the source #

1. Installing the fork #

First, you need to install react-native from your fork. For example, to install the master branch from the official repo, run the following:

npm install --save github:facebook/react-native#master

Alternatively, you can clone the repo to your node_modules directory and run npm install inside the cloned repo.

2. Adding gradle dependencies #

Add gradle-download-task as dependency in android/build.gradle:

... dependencies { @@ -44,6 +44,6 @@ dependencies { apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/android-setup.html b/docs/android-setup.html index ddcd26f0aa1..34afdab036c 100644 --- a/docs/android-setup.html +++ b/docs/android-setup.html @@ -1,6 +1,6 @@ -Android Setup – React Native | A framework for building native apps using React

Android Setup #

Edit on GitHub

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, Git is already installed, otherwise run the following:

    brew install git
  • On Linux, install Git via your package manager.

  • On Windows, download and install Git for Windows. 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
  2. Install the Android SDK:

Define the ANDROID_HOME environment variable #

IMPORTANT: Make sure the ANDROID_HOME environment variable points to your existing Android SDK:

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/android-ui-performance.html b/docs/android-ui-performance.html index 7bb07297f65..a45d6c0862f 100644 --- a/docs/android-ui-performance.html +++ b/docs/android-ui-performance.html @@ -1,4 +1,4 @@ -Profiling Android UI Performance – React Native | A framework for building native apps using React

Profiling Android UI Performance #

Edit on GitHub

We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).

The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...

Make sure that JS dev mode is OFF!

You should see __DEV__ === false, development-level warning are OFF, performance optimizations are ON in your application logs (which you can view using adb logcat)

Profiling with Systrace #

Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by markers start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.

Collecting a trace #

NOTE:

Systrace support was added in react-native v0.15. You will need to build with that version to collect a trace.

First, connect a device that exhibits the stuttering you want to investigate to your computer via USB and get it to the point right before the navigation/animation you want to profile. Run systrace as follows

$ <path_to_android_sdk>/platform-tools/systrace/systrace.py --time=10 -o trace.html sched gfx view -a <your_package_name>

A quick breakdown of this command:

  • time is the length of time the trace will be collected in seconds
  • sched, gfx, and view are the android SDK tags (collections of markers) we care about: sched gives you information about what's running on each core of your phone, gfx gives you graphics info such as frame boundaries, and view gives you information about measure, layout, and draw passes
  • -a <your_package_name> enables app-specific markers, specifically the ones built into the React Native framework. your_package_name can be found in the AndroidManifest.xml of your app and looks like com.example.app

Once the trace starts collecting, perform the animation or interaction you care about. At the end of the trace, systrace will give you a link to the trace which you can open in your browser.

Reading the trace #

After opening the trace in your browser (preferably Chrome), you should see something like this:

Example

HINT: Use the WASD keys to strafe and zoom

Enable VSync highlighting #

The first thing you should do is highlight the 16ms frame boundaries if you haven't already done that. Check this checkbox at the top right of the screen:

Enable VSync Highlighting

You should see zebra stripes as in the screenshot above. If you don't, try profiling on a different device: Samsung has been known to have issues displaying vsyncs while the Nexus series is generally pretty reliable.

Find your process #

Scroll until you see (part of) the name of your package. In this case, I was profiling com.facebook.adsmanager, which shows up as book.adsmanager because of silly thread name limits in the kernel.

On the left side, you'll see a set of threads which correspond to the timeline rows on the right. There are three/four threads we care about for our purposes: the UI thread (which has your package name or the name UI Thread), mqt_js and mqt_native_modules. If you're running on Android 5+, we also care about the Render Thread.

UI Thread #

This is where standard android measure/layout/draw happens. The thread name on the right will be your package name (in my case book.adsmanager) or UI Thread. The events that you see on this thread should look something like this and have to do with Choreographer, traversals, and DispatchUI:

UI Thread Example

JS Thread #

This is where JS is executed. The thread name will be either mqt_js or <...> depending on how cooperative the kernel on your device is being. To identify it if it doesn't have a name, look for things like JSCall, Bridge.executeJSCall, etc:

JS Thread Example

Native Modules Thread #

This is where native module calls (e.g. the UIManager) are executed. The thread name will be either mqt_native_modules or <...>. To identify it in the latter case, look for things like NativeCall, callJavaModuleMethod, and onBatchComplete:

Native Modules Thread Example

Bonus: Render Thread #

If you're using Android L (5.0) and up, you will also have a render thread in your application. This thread generates the actual OpenGL commands used to draw your UI. The thread name will be either RenderThread or <...>. To identify it in the latter case, look for things like DrawFrame and queueBuffer:

Render Thread Example

Identifying a culprit #

A smooth animation should look something like the following:

Smooth Animation

Each change in color is a frame -- remember that in order to display a frame, all our UI work needs to be done by the end of that 16ms period. Notice that no thread is working close to the frame boundary. An application rendering like this is rendering at 60FPS.

If you noticed chop, however, you might see something like this:

Choppy Animation from JS

Notice that the JS thread is executing basically all the time, and across frame boundaries! This app is not rendering at 60FPS. In this case, the problem lies in JS.

You might also see something like this:

Choppy Animation from UI

In this case, the UI and render threads are the ones that have work crossing frame boundaries. The UI that we're trying to render on each frame is requiring too much work to be done. In this case, the problem lies in the native views being rendered.

At this point, you'll have some very helpful information to inform your next steps.

JS Issues #

If you identified a JS problem, look for clues in the specific JS that you're executing. In the scenario above, we see RCTEventEmitter being called multiple times per frame. Here's a zoom-in of the JS thread from the trace above:

Too much JS

This doesn't seem right. Why is it being called so often? Are they actually different events? The answers to these questions will probably depend on your product code. And many times, you'll want to look into shouldComponentUpdate.

TODO: Add more tools for profiling JS

Native UI Issues #

If you identified a native UI problem, there are usually two scenarios:

  1. the UI you're trying to draw each frame involves to much work on the GPU, or
  2. You're constructing new UI during the animation/interaction (e.g. loading in new content during a scroll).

Too much GPU work #

In the first scenario, you'll see a trace that has the UI thread and/or Render Thread looking like this:

Overloaded GPU

Notice the long amount of time spent in DrawFrame that crosses frame boundaries. This is time spent waiting for the GPU to drain its command buffer from the previous frame.

To mitigate this, you should:

  • investigate using renderToHardwareTextureAndroid for complex, static content that is being animated/transformed (e.g. the Navigator slide/alpha animations)
  • make sure that you are not using needsOffscreenAlphaCompositing, which is disabled by default, as it greatly increases the per-frame load on the GPU in most cases.

If these don't help and you want to dig deeper into what the GPU is actually doing, you can check out Tracer for OpenGL ES.

Creating new views on the UI thread #

In the second scenario, you'll see something more like this:

Creating Views

Notice that first the JS thread thinks for a bit, then you see some work done on the native modules thread, followed by an expensive traversal on the UI thread.

There isn't an easy way to mitigate this unless you're able to postpone creating new UI until after the interaction, or you are able to simplify the UI you're creating. The react native team is working on a infrastructure level solution for this that will allow new UI to be created and configured off the main thread, allowing the interaction to continue smoothly.

Still stuck? #

If you are confused or stuck, please post ask on Stack Overflow with the react-native tag. If you are unable to get a response there, or find an issue with a core component, please File a Github issue.

© 2016 Facebook Inc.

Profiling Android UI Performance #

Edit on GitHub

We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).

The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...

Make sure that JS dev mode is OFF!

You should see __DEV__ === false, development-level warning are OFF, performance optimizations are ON in your application logs (which you can view using adb logcat)

Profiling with Systrace #

Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by markers start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.

Collecting a trace #

NOTE:

Systrace support was added in react-native v0.15. You will need to build with that version to collect a trace.

First, connect a device that exhibits the stuttering you want to investigate to your computer via USB and get it to the point right before the navigation/animation you want to profile. Run systrace as follows

$ <path_to_android_sdk>/platform-tools/systrace/systrace.py --time=10 -o trace.html sched gfx view -a <your_package_name>

A quick breakdown of this command:

  • time is the length of time the trace will be collected in seconds
  • sched, gfx, and view are the android SDK tags (collections of markers) we care about: sched gives you information about what's running on each core of your phone, gfx gives you graphics info such as frame boundaries, and view gives you information about measure, layout, and draw passes
  • -a <your_package_name> enables app-specific markers, specifically the ones built into the React Native framework. your_package_name can be found in the AndroidManifest.xml of your app and looks like com.example.app

Once the trace starts collecting, perform the animation or interaction you care about. At the end of the trace, systrace will give you a link to the trace which you can open in your browser.

Reading the trace #

After opening the trace in your browser (preferably Chrome), you should see something like this:

Example

HINT: Use the WASD keys to strafe and zoom

Enable VSync highlighting #

The first thing you should do is highlight the 16ms frame boundaries if you haven't already done that. Check this checkbox at the top right of the screen:

Enable VSync Highlighting

You should see zebra stripes as in the screenshot above. If you don't, try profiling on a different device: Samsung has been known to have issues displaying vsyncs while the Nexus series is generally pretty reliable.

Find your process #

Scroll until you see (part of) the name of your package. In this case, I was profiling com.facebook.adsmanager, which shows up as book.adsmanager because of silly thread name limits in the kernel.

On the left side, you'll see a set of threads which correspond to the timeline rows on the right. There are three/four threads we care about for our purposes: the UI thread (which has your package name or the name UI Thread), mqt_js and mqt_native_modules. If you're running on Android 5+, we also care about the Render Thread.

UI Thread #

This is where standard android measure/layout/draw happens. The thread name on the right will be your package name (in my case book.adsmanager) or UI Thread. The events that you see on this thread should look something like this and have to do with Choreographer, traversals, and DispatchUI:

UI Thread Example

JS Thread #

This is where JS is executed. The thread name will be either mqt_js or <...> depending on how cooperative the kernel on your device is being. To identify it if it doesn't have a name, look for things like JSCall, Bridge.executeJSCall, etc:

JS Thread Example

Native Modules Thread #

This is where native module calls (e.g. the UIManager) are executed. The thread name will be either mqt_native_modules or <...>. To identify it in the latter case, look for things like NativeCall, callJavaModuleMethod, and onBatchComplete:

Native Modules Thread Example

Bonus: Render Thread #

If you're using Android L (5.0) and up, you will also have a render thread in your application. This thread generates the actual OpenGL commands used to draw your UI. The thread name will be either RenderThread or <...>. To identify it in the latter case, look for things like DrawFrame and queueBuffer:

Render Thread Example

Identifying a culprit #

A smooth animation should look something like the following:

Smooth Animation

Each change in color is a frame -- remember that in order to display a frame, all our UI work needs to be done by the end of that 16ms period. Notice that no thread is working close to the frame boundary. An application rendering like this is rendering at 60FPS.

If you noticed chop, however, you might see something like this:

Choppy Animation from JS

Notice that the JS thread is executing basically all the time, and across frame boundaries! This app is not rendering at 60FPS. In this case, the problem lies in JS.

You might also see something like this:

Choppy Animation from UI

In this case, the UI and render threads are the ones that have work crossing frame boundaries. The UI that we're trying to render on each frame is requiring too much work to be done. In this case, the problem lies in the native views being rendered.

At this point, you'll have some very helpful information to inform your next steps.

JS Issues #

If you identified a JS problem, look for clues in the specific JS that you're executing. In the scenario above, we see RCTEventEmitter being called multiple times per frame. Here's a zoom-in of the JS thread from the trace above:

Too much JS

This doesn't seem right. Why is it being called so often? Are they actually different events? The answers to these questions will probably depend on your product code. And many times, you'll want to look into shouldComponentUpdate.

TODO: Add more tools for profiling JS

Native UI Issues #

If you identified a native UI problem, there are usually two scenarios:

  1. the UI you're trying to draw each frame involves to much work on the GPU, or
  2. You're constructing new UI during the animation/interaction (e.g. loading in new content during a scroll).

Too much GPU work #

In the first scenario, you'll see a trace that has the UI thread and/or Render Thread looking like this:

Overloaded GPU

Notice the long amount of time spent in DrawFrame that crosses frame boundaries. This is time spent waiting for the GPU to drain its command buffer from the previous frame.

To mitigate this, you should:

  • investigate using renderToHardwareTextureAndroid for complex, static content that is being animated/transformed (e.g. the Navigator slide/alpha animations)
  • make sure that you are not using needsOffscreenAlphaCompositing, which is disabled by default, as it greatly increases the per-frame load on the GPU in most cases.

If these don't help and you want to dig deeper into what the GPU is actually doing, you can check out Tracer for OpenGL ES.

Creating new views on the UI thread #

In the second scenario, you'll see something more like this:

Creating Views

Notice that first the JS thread thinks for a bit, then you see some work done on the native modules thread, followed by an expensive traversal on the UI thread.

There isn't an easy way to mitigate this unless you're able to postpone creating new UI until after the interaction, or you are able to simplify the UI you're creating. The react native team is working on a infrastructure level solution for this that will allow new UI to be created and configured off the main thread, allowing the interaction to continue smoothly.

Still stuck? #

If you are confused or stuck, please post ask on Stack Overflow with the react-native tag. If you are unable to get a response there, or find an issue with a core component, please File a Github issue.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/animated.html b/docs/animated.html index 29deb4f083c..28130d1b5f0 100644 --- a/docs/animated.html +++ b/docs/animated.html @@ -1,4 +1,4 @@ -Animated – React Native | A framework for building native apps using React

Animated #

Edit on GitHub

Animations are an important part of modern UX, and the Animated +Animated – React Native | A framework for building native apps using React

Animated #

Edit on GitHub

Animations are an important part of modern UX, and the Animated library is designed to make them fluid, powerful, and easy to build and maintain.

The simplest workflow is to create an Animated.Value, hook it up to one or more style attributes of an animated component, and then drive updates either @@ -58,18 +58,18 @@ event loop. This does influence the API, so keep that in mind when it seems a little trickier to do something compared to a fully synchronous system. Checkout Animated.Value.addListener as a way to work around some of these limitations, but use it sparingly since it might have performance -implications in the future.

Methods #

static decay(value: AnimatedValue | AnimatedValueXY, config: DecayAnimationConfig) #

Animates a value from an initial velocity to zero based on a decay -coefficient.

static timing(value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig) #

Animates a value along a timed easing curve. The Easing module has tons -of pre-defined curves, or you can use your own function.

static spring(value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig) #

Spring animation based on Rebound and Origami. Tracks velocity state to -create fluid motions as the toValue updates, and can be chained together.

static add(a: Animated, b: Animated) #

Creates a new Animated value composed from two Animated values added -together.

static multiply(a: Animated, b: Animated) #

Creates a new Animated value composed from two Animated values multiplied -together.

static modulo(a: Animated, modulus: number) #

Creates a new Animated value that is the (non-negative) modulo of the -provided Animated value

static delay(time: number) #

Starts an animation after the given delay.

static sequence(animations: Array<CompositeAnimation>) #

Starts an array of animations in order, waiting for each to complete +implications in the future.

Methods #

static decay(value, config) #

Animates a value from an initial velocity to zero based on a decay +coefficient.

static timing(value, config) #

Animates a value along a timed easing curve. The Easing module has tons +of pre-defined curves, or you can use your own function.

static spring(value, config) #

Spring animation based on Rebound and Origami. Tracks velocity state to +create fluid motions as the toValue updates, and can be chained together.

static add(a, b) #

Creates a new Animated value composed from two Animated values added +together.

static multiply(a, b) #

Creates a new Animated value composed from two Animated values multiplied +together.

static modulo(a, modulus) #

Creates a new Animated value that is the (non-negative) modulo of the +provided Animated value

static delay(time) #

Starts an animation after the given delay.

static sequence(animations) #

Starts an array of animations in order, waiting for each to complete before starting the next. If the current running animation is stopped, no -following animations will be started.

static parallel(animations: Array<CompositeAnimation>, config?: ParallelConfig) #

Starts an array of animations all at the same time. By default, if one +following animations will be started.

static parallel(animations, config?) #

Starts an array of animations all at the same time. By default, if one of the animations is stopped, they will all be stopped. You can override -this with the stopTogether flag.

static stagger(time: number, animations: Array<CompositeAnimation>) #

Array of animations may run in parallel (overlap), but are started in -sequence with successive delays. Nice for doing trailing effects.

static event(argMapping: Array<Mapping>, config?: EventConfig) #

Takes an array of mappings and extracts values from each arg accordingly, +this with the stopTogether flag.

static stagger(time, animations) #

Array of animations may run in parallel (overlap), but are started in +sequence with successive delays. Nice for doing trailing effects.

static event(argMapping, config?) #

Takes an array of mappings and extracts values from each arg accordingly, then calls setValue on the mapped outputs. e.g.

onScroll={Animated.event( [{nativeEvent: {contentOffset: {x: this._scrollX}}}] {listener}, // Optional async listener @@ -78,21 +78,21 @@ sequence with successive delays. Nice for doing trailing effects.

: Animated.event([ null, // raw event arg ignored {dx: this._panX}, // gestureState arg - ]),

static createAnimatedComponent(Component: any) #

Make any React component Animatable. Used to create Animated.View, etc.

Properties #

Value: AnimatedValue #

Standard value class for driving animations. Typically initialized with + ]),

static createAnimatedComponent(Component) #

Make any React component Animatable. Used to create Animated.View, etc.

Properties #

Value: AnimatedValue #

Standard value class for driving animations. Typically initialized with new Animated.Value(0);

ValueXY: AnimatedValueXY #

2D value class for driving 2D animations, such as pan gestures.

class AnimatedValue #

    Standard value for driving animations. One Animated.Value can drive multiple properties in a synchronized fashion, but can only be driven by one mechanism at a time. Using a new mechanism (e.g. starting a new animation, -or calling setValue) will stop any previous ones.

    Methods #

    constructor(value: number) #

    setValue(value: number) #

    Directly set the value. This will stop any animations running on the value -and update all the bound properties.

    setOffset(offset: number) #

    Sets an offset that is applied on top of whatever value is set, whether via +or calling setValue) will stop any previous ones.

    Methods #

    constructor(value) #

    setValue(value) #

    Directly set the value. This will stop any animations running on the value +and update all the bound properties.

    setOffset(offset) #

    Sets an offset that is applied on top of whatever value is set, whether via setValue, an animation, or Animated.event. Useful for compensating things like the start of a pan gesture.

    flattenOffset() #

    Merges the offset value into the base value and resets the offset to zero. -The final output of the value is unchanged.

    addListener(callback: ValueListenerCallback) #

    Adds an asynchronous listener to the value so you can observe updates from +The final output of the value is unchanged.

    addListener(callback) #

    Adds an asynchronous listener to the value so you can observe updates from animations. This is useful because there is no way to -synchronously read the value because it might be driven natively.

    removeListener(id: string) #

    removeAllListeners() #

    stopAnimation(callback?: ?(value: number) => void) #

    Stops any running animation or tracking. callback is invoked with the +synchronously read the value because it might be driven natively.

    removeListener(id) #

    removeAllListeners() #

    stopAnimation(callback?) #

    Stops any running animation or tracking. callback is invoked with the final value after stopping the animation, which is useful for updating -state to match the animation position with layout.

    interpolate(config: InterpolationConfigType) #

    Interpolates the value before updating the property, e.g. mapping 0-1 to -0-10.

    animate(animation: Animation, callback: EndCallback) #

    Typically only used internally, but could be used by a custom Animation -class.

    stopTracking() #

    Typically only used internally.

    track(tracking: Animated) #

    Typically only used internally.

class AnimatedValueXY #

    2D Value for driving 2D animations, such as pan gestures. Almost identical +state to match the animation position with layout.

interpolate(config) #

Interpolates the value before updating the property, e.g. mapping 0-1 to +0-10.

animate(animation, callback) #

Typically only used internally, but could be used by a custom Animation +class.

stopTracking() #

Typically only used internally.

track(tracking) #

Typically only used internally.

class AnimatedValueXY #

    2D Value for driving 2D animations, such as pan gestures. Almost identical API to normal Animated.Value, but multiplexed. Contains two regular Animated.Values under the hood. Example:

    class DraggableView extends React.Component { constructor(props) { @@ -123,18 +123,19 @@ API to normal Animated.Value, but multiplexed. Contains two regula </Animated.View> ); } - }

    Methods #

    constructor(valueIn?: ?{x: number | AnimatedValue; y: number | AnimatedValue}) #

    setValue(value: {x: number; y: number}) #

    setOffset(offset: {x: number; y: number}) #

    flattenOffset() #

    stopAnimation(callback?: ?() => number) #

    addListener(callback: ValueXYListenerCallback) #

    removeListener(id: string) #

    getLayout() #

    Converts {x, y} into {left, top} for use in style, e.g.

    style={this.state.anim.getLayout()}

    getTranslateTransform() #

    Converts {x, y} into a useable translation transform, e.g.

    style={{ + }

    Methods #

    constructor(valueIn?) #

    setValue(value) #

    setOffset(offset) #

    flattenOffset() #

    stopAnimation(callback?) #

    addListener(callback) #

    removeListener(id) #

    getLayout() #

    Converts {x, y} into {left, top} for use in style, e.g.

    style={this.state.anim.getLayout()}

    getTranslateTransform() #

    Converts {x, y} into a useable translation transform, e.g.

    style={{ transform: this.state.anim.getTranslateTransform() }}

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Animated, Easing, StyleSheet, Text, View, -} = React; +} = ReactNative; var UIExplorerButton = require('./UIExplorerButton'); exports.framework = 'React'; @@ -360,6 +361,6 @@ exports.examples \ No newline at end of file diff --git a/docs/animations.html b/docs/animations.html index c698f5e2972..1841041c3e5 100644 --- a/docs/animations.html +++ b/docs/animations.html @@ -1,4 +1,4 @@ -Animations – React Native | A framework for building native apps using React

Animations #

Edit on GitHub

Fluid, meaningful animations are essential to the mobile user experience. Like +Animations – React Native | A framework for building native apps using React

Animations #

Edit on GitHub

Fluid, meaningful animations are essential to the mobile user experience. Like everything in React Native, Animation APIs for React Native are currently under development, but have started to coalesce around two complementary systems: LayoutAnimation for animated global layout transactions, and Animated for @@ -149,23 +149,25 @@ row below which would otherwise require explicit coordination between the components in order to animate them all in sync.

Note that although LayoutAnimation is very powerful and can be quite useful, it provides much less control than Animated and other animation libraries, so you may need to use another approach if you can't get LayoutAnimation to do -what you want.

Note that in order to get this to work on Android you need to set the following flags via UIManager:

UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);

var App = React.createClass({ +what you want.

Note that in order to get this to work on Android you need to set the following flags via UIManager:

UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);

class App extends React.Component { + constructor(props) { + super(props); + this.state = { w: 100, h: 100 }; + this._onPress = this._onPress.bind(this); + } + componentWillMount() { // Animate creation LayoutAnimation.spring(); }, - getInitialState() { - return { w: 100, h: 100 } - }, - _onPress() { // Animate the update LayoutAnimation.spring(); this.setState({w: this.state.w + 15, h: this.state.h + 15}) - }, + } - render: function() { + render() { return ( <View style={styles.container}> <View style={[styles.box, {width: this.state.w, height: this.state.h}]} /> @@ -177,7 +179,7 @@ what you want.

Note that in order to get this to work on Android/View> ); } -});

Run this example

This example uses a preset value, you can customize the animations as +};

Run this example

This example uses a preset value, you can customize the animations as you need, see LayoutAnimation.js for more information.

requestAnimationFrame #

requestAnimationFrame is a polyfill from the browser that you might be familiar with. It accepts a function as its only argument and calls that @@ -201,13 +203,14 @@ provides a selection of popular ea that can be applied to make your animations more pleasing.

This library does not ship with React Native - in order to use it on your project, you will need to install it with npm i react-tween-state --save from your project directory.

Run this example

Here we animated the opacity, but as you might guess, we can animate any + } +} + +reactMixin.onClass(App, tweenState.Mixin);

Run this example

Here we animated the opacity, but as you might guess, we can animate any numeric value. Read more about react-tween-state in its README.

Rebound (Not recommended - use Animated instead) #

Rebound.js is a JavaScript port of Rebound for Android. It is @@ -243,7 +248,12 @@ by React Native on Navigator and WarningBox.

import rebound from 'rebound'; -var App = React.createClass({ +class App extends React.Component { + constructor(props) { + super(props); + this._onPressIn = this._onPressIn.bind(this); + this._onPressOut = this._onPressOut.bind(this); + } // First we initialize the spring and add a listener, which calls // setState whenever it updates componentWillMount() { @@ -262,17 +272,17 @@ the original value.

import rebound fro // Initialize the spring value at 1 this._scrollSpring.setCurrentValue(1); - }, + } _onPressIn() { this._scrollSpring.setEndValue(0.5); - }, + } _onPressOut() { this._scrollSpring.setEndValue(1); - }, + } - render: function() { + render() { var imageStyle = { width: 250, height: 200, @@ -290,7 +300,7 @@ the original value.

import rebound fro </View> ); } -});

Run this example

You can also clamp the spring values so that they don't overshoot and +}

Run this example

You can also clamp the spring values so that they don't overshoot and oscillate around the end value. In the above example, we would add this._scrollSpring.setOvershootClampingEnabled(true) to change this. See the below gif for an example of where in your interface you might @@ -316,7 +326,7 @@ and hasn't been optimized with shouldComponentUpdate.

// transform via style (avoid clashes when re-rendering) and to set the // photo ref -render: function() { +render() { return ( <View style={styles.container}> <TouchableWithoutFeedback onPressIn={this._onPressIn} onPressOut={this._onPressOut}> @@ -381,6 +391,6 @@ source.

\ No newline at end of file diff --git a/docs/appregistry.html b/docs/appregistry.html index 30ce17969a2..8439cceb651 100644 --- a/docs/appregistry.html +++ b/docs/appregistry.html @@ -1,4 +1,4 @@ -AppRegistry – React Native | A framework for building native apps using React

AppRegistry #

Edit on GitHub

AppRegistry is the JS entry point to running all React Native apps. App +AppRegistry – React Native | A framework for building native apps using React

AppRegistry #

Edit on GitHub

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 for the app and then actually run the app when it's ready by invoking @@ -6,7 +6,7 @@ for the app and then actually run the app when it's ready by invoking AppRegistry.unmountApplicationComponentAtRootTag with the tag that was pass into runApplication. These should always be used as a pair.

AppRegistry should be required early in the require sequence to make sure the JS execution environment is setup before other modules are -required.

Methods #

static registerConfig(config: Array<AppConfig>) #

static registerComponent(appKey: string, getComponentFunc: ComponentProvider) #

static registerRunnable(appKey: string, func: Function) #

static getAppKeys() #

static runApplication(appKey: string, appParameters: any) #

static unmountApplicationComponentAtRootTag(rootTag: number) #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/appstate.html b/docs/appstate.html index 73c6fd7e244..b4512d78ae9 100644 --- a/docs/appstate.html +++ b/docs/appstate.html @@ -1,4 +1,4 @@ -AppState – React Native | A framework for building native apps using React

AppState #

Edit on GitHub

AppState can tell you if the app is in the foreground or background, +AppState – React Native | A framework for building native apps using React

AppState #

Edit on GitHub

AppState can tell you if the app is in the foreground or background, and notify you when the state changes.

AppState is frequently used to determine the intent and proper behavior when handling push notifications.

App States #

  • active - The app is running in the foreground
  • background - The app is running in the background. The user is either in another app or on the home screen
  • inactive - This is a transition state that currently never happens for @@ -25,15 +25,16 @@ render: funct ); },

This example will only ever appear to say "Current state is: active" because the app is only visible to the user when in the active state, and the null -state will happen only momentarily.

Methods #

static addEventListener(type: string, handler: Function) #

Add a handler to AppState changes by listening to the change event type -and providing the handler

static removeEventListener(type: string, handler: Function) #

Remove a handler by passing the change event type and the handler

Properties #

currentState: TypeCastExpression #

Examples #

Edit on GitHub
'use strict'; +state will happen only momentarily.

Methods #

static addEventListener(type, handler) #

Add a handler to AppState changes by listening to the change event type +and providing the handler

static removeEventListener(type, handler) #

Remove a handler by passing the change event type and the handler

Properties #

currentState: TypeCastExpression #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { AppState, Text, View -} = React; +} = ReactNative; var AppStateSubscription = React.createClass({ getInitialState() { @@ -105,6 +106,6 @@ exports.examples \ No newline at end of file diff --git a/docs/appstateios.html b/docs/appstateios.html index b81893bfa49..341ed5a05ec 100644 --- a/docs/appstateios.html +++ b/docs/appstateios.html @@ -1,4 +1,4 @@ -AppStateIOS – React Native | A framework for building native apps using React

AppStateIOS #

Edit on GitHub

AppStateIOS can tell you if the app is in the foreground or background, +AppStateIOS – React Native | A framework for building native apps using React

AppStateIOS #

Edit on GitHub

AppStateIOS can tell you if the app is in the foreground or background, and notify you when the state changes.

AppStateIOS is frequently used to determine the intent and proper behavior when handling push notifications.

iOS App States #

  • active - The app is running in the foreground
  • background - The app is running in the background. The user is either in another app or on the home screen
  • inactive - This is a state that occurs when transitioning between @@ -26,18 +26,19 @@ render: funct ); },

This example will only ever appear to say "Current state is: active" because the app is only visible to the user when in the active state, and the null -state will happen only momentarily.

Methods #

static addEventListener(type: string, handler: Function) #

Add a handler to AppState changes by listening to the change event type -and providing the handler

static removeEventListener(type: string, handler: Function) #

Remove a handler by passing the change event type and the handler

Properties #

currentState: TypeCastExpression #

// TODO: getCurrentAppState callback seems to be called at a really late stage +state will happen only momentarily.

Methods #

static addEventListener(type, handler) #

Add a handler to AppState changes by listening to the change event type +and providing the handler

static removeEventListener(type, handler) #

Remove a handler by passing the change event type and the handler

Properties #

currentState: TypeCastExpression #

// TODO: getCurrentAppState callback seems to be called at a really late stage // after app launch. Trying to get currentState when mounting App component // will likely to have the initial value here. // Initialize to 'active' instead of null.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { AppStateIOS, Text, View -} = React; +} = ReactNative; var AppStateSubscription = React.createClass({ getInitialState() { @@ -127,6 +128,6 @@ exports.examples \ No newline at end of file diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html index 0d651778eb5..39a6f5097d6 100644 --- a/docs/asyncstorage.html +++ b/docs/asyncstorage.html @@ -1,11 +1,13 @@ -AsyncStorage – React Native | A framework for building native apps using React

AsyncStorage #

Edit on GitHub

AsyncStorage is a simple, asynchronous, persistent, key-value storage +AsyncStorage – React Native | A framework for building native apps using React

AsyncStorage #

Edit on GitHub

AsyncStorage is a simple, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage.

It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since it -operates globally.

This JS code is a simple facade over the native iOS implementation to provide -a clear JS API, real Error objects, and simple non-multi functions. Each -method returns a Promise object.

Methods #

static getItem(key: string, callback?: ?(error: ?Error, result: ?string) => void) #

Fetches key and passes the result to callback, along with an Error if -there is any. Returns a Promise object.

static setItem(key: string, value: string, callback?: ?(error: ?Error) => void) #

Sets value for key and calls callback on completion, along with an -Error if there is any. Returns a Promise object.

static removeItem(key: string, callback?: ?(error: ?Error) => void) #

Returns a Promise object.

static mergeItem(key: string, value: string, callback?: ?(error: ?Error) => void) #

Merges existing value with input value, assuming they are stringified json. +operates globally.

On iOS, AsyncStorage is backed by native code that stores small values in a serialized +dictionary and larger values in separate files. On Android, AsyncStorage will use either +RocksDB or SQLite based on what is available. This JS code is a simple facade that +provides a clear JS API, real Error objects, and simple non-multi functions. Each +method returns a Promise object.

Methods #

static getItem(key, callback?) #

Fetches key and passes the result to callback, along with an Error if +there is any. Returns a Promise object.

static setItem(key, value, callback?) #

Sets value for key and calls callback on completion, along with an +Error if there is any. Returns a Promise object.

static removeItem(key, callback?) #

Returns a Promise object.

static mergeItem(key, value, callback?) #

Merges existing value with input value, assuming they are stringified json. Returns a Promise object. Not supported by all native implementations.

Example:

let UID123_object = { name: 'Chris', age: 30, @@ -25,9 +27,9 @@ AsyncStorage. // => {'name':'Chris','age':31,'traits':{'shoe_size':10,'hair':'brown','eyes':'blue'}} }); }); -});

static clear(callback?: ?(error: ?Error) => void) #

Erases all AsyncStorage for all clients, libraries, etc. You probably +});

static clear(callback?) #

Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this - use removeItem or multiRemove to clear only your -own keys instead. Returns a Promise object.

static getAllKeys(callback?: ?(error: ?Error, keys: ?Array<string>) => void) #

Gets all keys known to the app, for all callers, libraries, etc. Returns a Promise object.

Example: see multiGet for example

static flushGetRequests() #

Flushes any pending requests using a single multiget

static multiGet(keys: Array<string>, callback?: ?(errors: ?Array<Error>, result: ?Array<Array<string>>) => void) #

multiGet invokes callback with an array of key-value pair arrays that +own keys instead. Returns a Promise object.

static getAllKeys(callback?) #

Gets all keys known to the app, for all callers, libraries, etc. Returns a Promise object.

Example: see multiGet for example

static flushGetRequests() #

Flushes any pending requests using a single multiget

static multiGet(keys, callback?) #

multiGet invokes callback with an array of key-value pair arrays that matches the input format of multiSet. Returns a Promise object.

multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']])

Example:

AsyncStorage.getAllKeys((err, keys) => { AsyncStorage.multiGet(keys, (err, stores) => { stores.map((result, i, store) => { @@ -36,12 +38,12 @@ matches the input format of multiSet. Returns a Promise object.

let value = store[i][1]; }); }); -});

static multiSet(keyValuePairs: Array<Array<string>>, callback?: ?(errors: ?Array<Error>) => void) #

multiSet and multiMerge take arrays of key-value array pairs that match -the output of multiGet, e.g. Returns a Promise object.

multiSet([['k1', 'val1'], ['k2', 'val2']], cb);

Example: see multiMerge for an example

static multiRemove(keys: Array<string>, callback?: ?(errors: ?Array<Error>) => void) #

Delete all the keys in the keys array. Returns a Promise object.

Example:

let keys = ['k1', 'k2']; +});

static multiSet(keyValuePairs, callback?) #

multiSet and multiMerge take arrays of key-value array pairs that match +the output of multiGet, e.g. Returns a Promise object.

multiSet([['k1', 'val1'], ['k2', 'val2']], cb);

Example: see multiMerge for an example

static multiRemove(keys, callback?) #

Delete all the keys in the keys array. Returns a Promise object.

Example:

let keys = ['k1', 'k2']; AsyncStorage.multiRemove(keys, (err) => { // keys k1 & k2 removed, if they existed // do most stuff after removal (if you want) -});

static multiMerge(keyValuePairs: Array<Array<string>>, callback?: ?(errors: ?Array<Error>) => void) #

Merges existing values with input values, assuming they are stringified +});

static multiMerge(keyValuePairs, callback?) #

Merges existing values with input values, assuming they are stringified json. Returns a Promise object.

Not supported by all native implementations.

Example:

// first user, initial values let UID234_object = { name: 'Chris', @@ -85,13 +87,14 @@ AsyncStorage.}); });

Properties #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { AsyncStorage, PickerIOS, Text, View -} = React; +} = ReactNative; var PickerItemIOS = PickerIOS.Item; var STORAGE_KEY = '@AsyncStorageExample:key'; @@ -202,6 +205,6 @@ exports.examples \ No newline at end of file diff --git a/docs/backandroid.html b/docs/backandroid.html index ed360a8ccd7..aab274b9085 100644 --- a/docs/backandroid.html +++ b/docs/backandroid.html @@ -1,11 +1,11 @@ -BackAndroid – React Native | A framework for building native apps using React

BackAndroid #

Edit on GitHub

Detect hardware back button presses, and programmatically invoke the default back button +BackAndroid – React Native | A framework for building native apps using React

BackAndroid #

Edit on GitHub

Detect hardware back button presses, and programmatically invoke the default back button functionality to exit the app if there are no listeners or if none of the listeners return true.

Example:

BackAndroid.addEventListener('hardwareBackPress', function() { if (!this.onMainScreen()) { this.goBack(); return true; } return false; -});

Methods #

static exitApp() #

static addEventListener(eventName: BackPressEventName, handler: Function) #

static removeEventListener(eventName: BackPressEventName, handler: Function) #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/cameraroll.html b/docs/cameraroll.html index 53222f928a9..8ebe2081312 100644 --- a/docs/cameraroll.html +++ b/docs/cameraroll.html @@ -1,8 +1,9 @@ -CameraRoll – React Native | A framework for building native apps using React

CameraRoll #

Edit on GitHub

CameraRoll provides access to the local camera roll / gallery.

Methods #

static saveImageWithTag(tag) #

Saves the image to the camera roll / gallery.

On Android, the tag is a local URI, such as "file:///sdcard/img.png".

On iOS, the tag can be one of the following:

  • local URI
  • assets-library tag
  • a tag not matching any of the above, which means the image data will -be stored in memory (and consume memory as long as the process is alive)

Returns a Promise which when resolved will be passed the new URI.

static getPhotos(params: object) #

Returns a Promise with photo identifier objects from the local camera +CameraRoll – React Native | A framework for building native apps using React

CameraRoll #

Edit on GitHub

CameraRoll provides access to the local camera roll / gallery.

Methods #

static saveImageWithTag(tag) #

Saves the image to the camera roll / gallery.

On Android, the tag is a local URI, such as "file:///sdcard/img.png".

On iOS, the tag can be one of the following:

  • local URI
  • assets-library tag
  • a tag not matching any of the above, which means the image data will +be stored in memory (and consume memory as long as the process is alive)

Returns a Promise which when resolved will be passed the new URI.

static getPhotos(params) #

Returns a Promise with photo identifier objects from the local camera roll of the device matching shape defined by getPhotosReturnChecker.

@param {object} params See getPhotosParamChecker.

Returns a Promise which when resolved will be of shape getPhotosReturnChecker.

Examples #

Edit on GitHub
'use strict'; -const React = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); const { CameraRoll, Image, @@ -12,7 +13,7 @@ const { Text, View, TouchableOpacity -} = React; +} = ReactNative; const CameraRollView = require('./CameraRollView'); @@ -141,6 +142,6 @@ exports.examples \ No newline at end of file diff --git a/docs/clipboard.html b/docs/clipboard.html index 599341f2c60..600f02ebffb 100644 --- a/docs/clipboard.html +++ b/docs/clipboard.html @@ -1,15 +1,16 @@ -Clipboard – React Native | A framework for building native apps using React

Clipboard #

Edit on GitHub

Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and Android

Methods #

static getString() #

Get content of string type, this method returns a Promise, so you can use following code to get clipboard content

async _getContent() { +Clipboard – React Native | A framework for building native apps using React

Clipboard #

Edit on GitHub

Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and Android

Methods #

static getString() #

Get content of string type, this method returns a Promise, so you can use following code to get clipboard content

async _getContent() { var content = await Clipboard.getString(); -}

static setString(content: string) #

Set content of string type. You can use following code to set clipboard content

_setContent() { +}

static setString(content) #

Set content of string type. You can use following code to set clipboard content

_setContent() { Clipboard.setString('hello world'); }

@param the content to be stored in the clipboard.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Clipboard, View, Text, -} = React; +} = ReactNative; var ClipboardExample = React.createClass({ getInitialState() { @@ -67,6 +68,6 @@ exports.examples \ No newline at end of file diff --git a/docs/colors.html b/docs/colors.html index e11e329d002..1dd551a0073 100644 --- a/docs/colors.html +++ b/docs/colors.html @@ -1,4 +1,4 @@ -Colors – React Native | A framework for building native apps using React

Colors #

Edit on GitHub

The following formats are supported:

  • '#f0f' (#rgb)
  • '#f0fc' (#rgba)
  • '#ff00ff' (#rrggbb)
  • '#ff00ff00' (#rrggbbaa)
  • 'rgb(255, 255, 255)'
  • 'rgba(255, 255, 255, 1.0)'
  • 'hsl(360, 100%, 100%)'
  • 'hsla(360, 100%, 100%, 1.0)'
  • 'transparent'
  • 'red'
  • 0xff00ff00 (0xrrggbbaa)

For the named colors, React Native follows the CSS3 specification:

  • aliceblue (#f0f8ff)
  • antiquewhite (#faebd7)
  • aqua (#00ffff)
  • aquamarine (#7fffd4)
  • azure (#f0ffff)
  • beige (#f5f5dc)
  • bisque (#ffe4c4)
  • black (#000000)
  • blanchedalmond (#ffebcd)
  • blue (#0000ff)
  • blueviolet (#8a2be2)
  • brown (#a52a2a)
  • burlywood (#deb887)
  • cadetblue (#5f9ea0)
  • chartreuse (#7fff00)
  • chocolate (#d2691e)
  • coral (#ff7f50)
  • cornflowerblue (#6495ed)
  • cornsilk (#fff8dc)
  • crimson (#dc143c)
  • cyan (#00ffff)
  • darkblue (#00008b)
  • darkcyan (#008b8b)
  • darkgoldenrod (#b8860b)
  • darkgray (#a9a9a9)
  • darkgreen (#006400)
  • darkgrey (#a9a9a9)
  • darkkhaki (#bdb76b)
  • darkmagenta (#8b008b)
  • darkolivegreen (#556b2f)
  • darkorange (#ff8c00)
  • darkorchid (#9932cc)
  • darkred (#8b0000)
  • darksalmon (#e9967a)
  • darkseagreen (#8fbc8f)
  • darkslateblue (#483d8b)
  • darkslategray (#2f4f4f)
  • darkslategrey (#2f4f4f)
  • darkturquoise (#00ced1)
  • darkviolet (#9400d3)
  • deeppink (#ff1493)
  • deepskyblue (#00bfff)
  • dimgray (#696969)
  • dimgrey (#696969)
  • dodgerblue (#1e90ff)
  • firebrick (#b22222)
  • floralwhite (#fffaf0)
  • forestgreen (#228b22)
  • fuchsia (#ff00ff)
  • gainsboro (#dcdcdc)
  • ghostwhite (#f8f8ff)
  • gold (#ffd700)
  • goldenrod (#daa520)
  • gray (#808080)
  • green (#008000)
  • greenyellow (#adff2f)
  • grey (#808080)
  • honeydew (#f0fff0)
  • hotpink (#ff69b4)
  • indianred (#cd5c5c)
  • indigo (#4b0082)
  • ivory (#fffff0)
  • khaki (#f0e68c)
  • lavender (#e6e6fa)
  • lavenderblush (#fff0f5)
  • lawngreen (#7cfc00)
  • lemonchiffon (#fffacd)
  • lightblue (#add8e6)
  • lightcoral (#f08080)
  • lightcyan (#e0ffff)
  • lightgoldenrodyellow (#fafad2)
  • lightgray (#d3d3d3)
  • lightgreen (#90ee90)
  • lightgrey (#d3d3d3)
  • lightpink (#ffb6c1)
  • lightsalmon (#ffa07a)
  • lightseagreen (#20b2aa)
  • lightskyblue (#87cefa)
  • lightslategray (#778899)
  • lightslategrey (#778899)
  • lightsteelblue (#b0c4de)
  • lightyellow (#ffffe0)
  • lime (#00ff00)
  • limegreen (#32cd32)
  • linen (#faf0e6)
  • magenta (#ff00ff)
  • maroon (#800000)
  • mediumaquamarine (#66cdaa)
  • mediumblue (#0000cd)
  • mediumorchid (#ba55d3)
  • mediumpurple (#9370db)
  • mediumseagreen (#3cb371)
  • mediumslateblue (#7b68ee)
  • mediumspringgreen (#00fa9a)
  • mediumturquoise (#48d1cc)
  • mediumvioletred (#c71585)
  • midnightblue (#191970)
  • mintcream (#f5fffa)
  • mistyrose (#ffe4e1)
  • moccasin (#ffe4b5)
  • navajowhite (#ffdead)
  • navy (#000080)
  • oldlace (#fdf5e6)
  • olive (#808000)
  • olivedrab (#6b8e23)
  • orange (#ffa500)
  • orangered (#ff4500)
  • orchid (#da70d6)
  • palegoldenrod (#eee8aa)
  • palegreen (#98fb98)
  • paleturquoise (#afeeee)
  • palevioletred (#db7093)
  • papayawhip (#ffefd5)
  • peachpuff (#ffdab9)
  • peru (#cd853f)
  • pink (#ffc0cb)
  • plum (#dda0dd)
  • powderblue (#b0e0e6)
  • purple (#800080)
  • rebeccapurple (#663399)
  • red (#ff0000)
  • rosybrown (#bc8f8f)
  • royalblue (#4169e1)
  • saddlebrown (#8b4513)
  • salmon (#fa8072)
  • sandybrown (#f4a460)
  • seagreen (#2e8b57)
  • seashell (#fff5ee)
  • sienna (#a0522d)
  • silver (#c0c0c0)
  • skyblue (#87ceeb)
  • slateblue (#6a5acd)
  • slategray (#708090)
  • slategrey (#708090)
  • snow (#fffafa)
  • springgreen (#00ff7f)
  • steelblue (#4682b4)
  • tan (#d2b48c)
  • teal (#008080)
  • thistle (#d8bfd8)
  • tomato (#ff6347)
  • turquoise (#40e0d0)
  • violet (#ee82ee)
  • wheat (#f5deb3)
  • white (#ffffff)
  • whitesmoke (#f5f5f5)
  • yellow (#ffff00)
  • yellowgreen (#9acd32)
© 2016 Facebook Inc.

Colors #

Edit on GitHub

The following formats are supported:

  • '#f0f' (#rgb)
  • '#f0fc' (#rgba)
  • '#ff00ff' (#rrggbb)
  • '#ff00ff00' (#rrggbbaa)
  • 'rgb(255, 255, 255)'
  • 'rgba(255, 255, 255, 1.0)'
  • 'hsl(360, 100%, 100%)'
  • 'hsla(360, 100%, 100%, 1.0)'
  • 'transparent'
  • 'red'
  • 0xff00ff00 (0xrrggbbaa)

For the named colors, React Native follows the CSS3 specification:

  • aliceblue (#f0f8ff)
  • antiquewhite (#faebd7)
  • aqua (#00ffff)
  • aquamarine (#7fffd4)
  • azure (#f0ffff)
  • beige (#f5f5dc)
  • bisque (#ffe4c4)
  • black (#000000)
  • blanchedalmond (#ffebcd)
  • blue (#0000ff)
  • blueviolet (#8a2be2)
  • brown (#a52a2a)
  • burlywood (#deb887)
  • cadetblue (#5f9ea0)
  • chartreuse (#7fff00)
  • chocolate (#d2691e)
  • coral (#ff7f50)
  • cornflowerblue (#6495ed)
  • cornsilk (#fff8dc)
  • crimson (#dc143c)
  • cyan (#00ffff)
  • darkblue (#00008b)
  • darkcyan (#008b8b)
  • darkgoldenrod (#b8860b)
  • darkgray (#a9a9a9)
  • darkgreen (#006400)
  • darkgrey (#a9a9a9)
  • darkkhaki (#bdb76b)
  • darkmagenta (#8b008b)
  • darkolivegreen (#556b2f)
  • darkorange (#ff8c00)
  • darkorchid (#9932cc)
  • darkred (#8b0000)
  • darksalmon (#e9967a)
  • darkseagreen (#8fbc8f)
  • darkslateblue (#483d8b)
  • darkslategray (#2f4f4f)
  • darkslategrey (#2f4f4f)
  • darkturquoise (#00ced1)
  • darkviolet (#9400d3)
  • deeppink (#ff1493)
  • deepskyblue (#00bfff)
  • dimgray (#696969)
  • dimgrey (#696969)
  • dodgerblue (#1e90ff)
  • firebrick (#b22222)
  • floralwhite (#fffaf0)
  • forestgreen (#228b22)
  • fuchsia (#ff00ff)
  • gainsboro (#dcdcdc)
  • ghostwhite (#f8f8ff)
  • gold (#ffd700)
  • goldenrod (#daa520)
  • gray (#808080)
  • green (#008000)
  • greenyellow (#adff2f)
  • grey (#808080)
  • honeydew (#f0fff0)
  • hotpink (#ff69b4)
  • indianred (#cd5c5c)
  • indigo (#4b0082)
  • ivory (#fffff0)
  • khaki (#f0e68c)
  • lavender (#e6e6fa)
  • lavenderblush (#fff0f5)
  • lawngreen (#7cfc00)
  • lemonchiffon (#fffacd)
  • lightblue (#add8e6)
  • lightcoral (#f08080)
  • lightcyan (#e0ffff)
  • lightgoldenrodyellow (#fafad2)
  • lightgray (#d3d3d3)
  • lightgreen (#90ee90)
  • lightgrey (#d3d3d3)
  • lightpink (#ffb6c1)
  • lightsalmon (#ffa07a)
  • lightseagreen (#20b2aa)
  • lightskyblue (#87cefa)
  • lightslategray (#778899)
  • lightslategrey (#778899)
  • lightsteelblue (#b0c4de)
  • lightyellow (#ffffe0)
  • lime (#00ff00)
  • limegreen (#32cd32)
  • linen (#faf0e6)
  • magenta (#ff00ff)
  • maroon (#800000)
  • mediumaquamarine (#66cdaa)
  • mediumblue (#0000cd)
  • mediumorchid (#ba55d3)
  • mediumpurple (#9370db)
  • mediumseagreen (#3cb371)
  • mediumslateblue (#7b68ee)
  • mediumspringgreen (#00fa9a)
  • mediumturquoise (#48d1cc)
  • mediumvioletred (#c71585)
  • midnightblue (#191970)
  • mintcream (#f5fffa)
  • mistyrose (#ffe4e1)
  • moccasin (#ffe4b5)
  • navajowhite (#ffdead)
  • navy (#000080)
  • oldlace (#fdf5e6)
  • olive (#808000)
  • olivedrab (#6b8e23)
  • orange (#ffa500)
  • orangered (#ff4500)
  • orchid (#da70d6)
  • palegoldenrod (#eee8aa)
  • palegreen (#98fb98)
  • paleturquoise (#afeeee)
  • palevioletred (#db7093)
  • papayawhip (#ffefd5)
  • peachpuff (#ffdab9)
  • peru (#cd853f)
  • pink (#ffc0cb)
  • plum (#dda0dd)
  • powderblue (#b0e0e6)
  • purple (#800080)
  • rebeccapurple (#663399)
  • red (#ff0000)
  • rosybrown (#bc8f8f)
  • royalblue (#4169e1)
  • saddlebrown (#8b4513)
  • salmon (#fa8072)
  • sandybrown (#f4a460)
  • seagreen (#2e8b57)
  • seashell (#fff5ee)
  • sienna (#a0522d)
  • silver (#c0c0c0)
  • skyblue (#87ceeb)
  • slateblue (#6a5acd)
  • slategray (#708090)
  • slategrey (#708090)
  • snow (#fffafa)
  • springgreen (#00ff7f)
  • steelblue (#4682b4)
  • tan (#d2b48c)
  • teal (#008080)
  • thistle (#d8bfd8)
  • tomato (#ff6347)
  • turquoise (#40e0d0)
  • violet (#ee82ee)
  • wheat (#f5deb3)
  • white (#ffffff)
  • whitesmoke (#f5f5f5)
  • yellow (#ffff00)
  • yellowgreen (#9acd32)
© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/communication-ios.html b/docs/communication-ios.html index 849cfa57ad7..d12ef109d35 100644 --- a/docs/communication-ios.html +++ b/docs/communication-ios.html @@ -1,4 +1,4 @@ -Communication between native and React Native – React Native | A framework for building native apps using React

Communication between native and React Native #

Edit on GitHub

In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.

Introduction #

React Native is inspired by React, so the basic idea of the information flow is similar. The flow in React is one-directional. We maintain a hierarchy of components, in which each component depends only on its parent and own internal state. We do this with properties: data is passed from a parent to its children in a top-down manner. If we have an ancestor component that rely on the state of its descendant, the recommended solution would be to pass down a callback that would be used by the descendant to update the ancestor.

The same concept applies to React Native. As long as we are building our application purely within the framework, we can drive our app with properties and callbacks. But, when we mix React Native and native components, we need some special, cross-language mechanisms that would allow us to pass information between them.

Properties #

Properties are the simplest way of cross-component communication. So we need a way to pass properties both from native to React Native, and from React Native to native.

Passing properties from native to React Native #

In order to embed a React Native view in a native component, we use RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.

RCTRootView has an initializer that allows you to pass arbitrary properties down to the React Native app. The initialProperties parameter has to be an instance of NSDictionary. The dictionary is internally converted into a JSON object that the top-level JS component can reference.

NSArray *imageList = @[@"http://foo.com/bar1.png", +Communication between native and React Native – React Native | A framework for building native apps using React

Communication between native and React Native #

Edit on GitHub

In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.

Introduction #

React Native is inspired by React, so the basic idea of the information flow is similar. The flow in React is one-directional. We maintain a hierarchy of components, in which each component depends only on its parent and own internal state. We do this with properties: data is passed from a parent to its children in a top-down manner. If we have an ancestor component that rely on the state of its descendant, the recommended solution would be to pass down a callback that would be used by the descendant to update the ancestor.

The same concept applies to React Native. As long as we are building our application purely within the framework, we can drive our app with properties and callbacks. But, when we mix React Native and native components, we need some special, cross-language mechanisms that would allow us to pass information between them.

Properties #

Properties are the simplest way of cross-component communication. So we need a way to pass properties both from native to React Native, and from React Native to native.

Passing properties from native to React Native #

In order to embed a React Native view in a native component, we use RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.

RCTRootView has an initializer that allows you to pass arbitrary properties down to the React Native app. The initialProperties parameter has to be an instance of NSDictionary. The dictionary is internally converted into a JSON object that the top-level JS component can reference.

NSArray *imageList = @[@"http://foo.com/bar1.png", @"http://foo.com/bar2.png"]; NSDictionary *props = @{@"images" : imageList}; @@ -88,6 +88,6 @@ Making a dimension flexible in both JS and native leads to undefined behavior. F apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/datepickerandroid.html b/docs/datepickerandroid.html index 5f62b69b2e7..b029343448f 100644 --- a/docs/datepickerandroid.html +++ b/docs/datepickerandroid.html @@ -1,4 +1,4 @@ -DatePickerAndroid – React Native | A framework for building native apps using React

DatePickerAndroid #

Edit on GitHub

Opens the standard Android date picker dialog.

Example #

try { +DatePickerAndroid – React Native | A framework for building native apps using React

DatePickerAndroid #

Edit on GitHub

Opens the standard Android date picker dialog.

Example #

try { const {action, year, month, day} = await DatePickerAndroid.open({ // Use `new Date()` for current date. // May 25 2020. Month 0 is January. @@ -9,7 +9,7 @@ } } catch ({code, message}) { console.warn('Cannot open date picker', message); -}

Methods #

static open(options: Object) #

Opens the standard Android date picker dialog.

The available keys for the options object are: +}

Methods #

static open(options) #

Opens the standard Android date picker dialog.

The available keys for the options object are: date (Date object or timestamp in milliseconds) - date to show by default minDate (Date or timestamp in milliseconds) - minimum date that can be selected * maxDate (Date object or timestamp in milliseconds) - minimum date that can be selected

Returns a Promise which will be invoked an object containing action, year, month (0-11), @@ -18,13 +18,14 @@ still be resolved with action being DatePickerAndroid.dismissedActionAlways check whether the action before reading the values.

Note the native date picker dialog has some UI glitches on Android 4 and lower when using the minDate and maxDate options.

static dateSetAction() #

A date has been selected.

static dismissedAction() #

The dialog has been dismissed.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { DatePickerAndroid, StyleSheet, Text, TouchableWithoutFeedback, -} = React; +} = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); @@ -51,7 +52,7 @@ when using the minDate and maxDate options.

< async showPicker(stateKey, options) { try { var newState = {}; - const {action, year, month, day} = await DatePickerAndroid.open(options); + const {action, year, month, day} = await DatePickerAndroid.open(options); if (action === DatePickerAndroid.dismissedAction) { newState[stateKey + 'Text'] = 'dismissed'; } else { @@ -135,6 +136,6 @@ module.exports \ No newline at end of file diff --git a/docs/datepickerios.html b/docs/datepickerios.html index 889d361e380..4f6a3c2bfaf 100644 --- a/docs/datepickerios.html +++ b/docs/datepickerios.html @@ -1,4 +1,4 @@ -DatePickerIOS – React Native | A framework for building native apps using React

DatePickerIOS #

Edit on GitHub

Use DatePickerIOS to render a date/time picker (selector) on iOS. This is +DatePickerIOS – React Native | A framework for building native apps using React

DatePickerIOS #

Edit on GitHub

Use DatePickerIOS to render a date/time picker (selector) on iOS. This is a controlled component, so you must hook in to the onDateChange callback and update the date prop in order for the component to update, otherwise the user's change will be reverted immediately to reflect props.date as the @@ -8,14 +8,15 @@ date and time.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { DatePickerIOS, StyleSheet, Text, TextInput, View, -} = React; +} = ReactNative; var DatePickerExample = React.createClass({ getDefaultProps: function () { @@ -174,6 +175,6 @@ exports.examples \ No newline at end of file diff --git a/docs/debugging.html b/docs/debugging.html index ee87c7a14fe..280929d8ebb 100644 --- a/docs/debugging.html +++ b/docs/debugging.html @@ -1,4 +1,5 @@ -Debugging – React Native | A framework for building native apps using React

Debugging #

Edit on GitHub

Debugging React Native Apps #

To access the in-app developer menu:

  1. On iOS shake the device or press control + ⌘ + z in the simulator.
  2. On Android shake the device or press hardware menu button (available on older devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.

Hint

To disable the developer menu for production builds:

  1. For iOS open your project in Xcode and select ProductSchemeEdit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.
  2. For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gradle assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.

Android logging #

Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.

Reload #

Selecting Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.

YellowBox/RedBox #

Using console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.

You can use console.error to display a full screen error on a red background.

These boxes only appear when you're running your app in dev mode.

Chrome Developer Tools #

To debug the JavaScript code in Chrome, select Debug in Chrome from the developer menu. This will open a new tab at http://localhost:8081/debugger-ui.

In Chrome, press ⌘ + option + i or select ViewDeveloperDeveloper Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.

To debug on a real device:

  1. On iOS - open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
  2. On Android, if you're running Android 5.0+ device connected via USB you can use adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

Live Reload #

This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option:

  1. On iOS, select Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.
  2. On Android, launch dev menu, go to Dev Settings and select Auto reload on JS change option

FPS (Frames per Second) Monitor #

On 0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.

© 2016 Facebook Inc.

Debugging #

Edit on GitHub

Debugging React Native Apps #

To access the in-app developer menu:

  1. On iOS shake the device or press control + ⌘ + z in the simulator.
  2. On Android shake the device or press hardware menu button (available on older devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.

Hint

To disable the developer menu for production builds:

  1. For iOS open your project in Xcode and select ProductSchemeEdit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.
  2. For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gradle assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.

Android logging #

Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.

Reload #

Selecting Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.

YellowBox/RedBox #

Using console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.

You can use console.error to display a full screen error on a red background.

By default, the warning box is enabled in __DEV__. Set the following flag to disable it:

console.disableYellowBox = true; +console.warn('YellowBox is disabled.');

Specific warnings can be ignored programmatically by setting the array:

console.ignoredYellowBox = ['Warning: ...'];

Strings in console.ignoredYellowBox can be a prefix of the warning that should be ignored.

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.

In Chrome, press ⌘ + option + i or select ViewDeveloperDeveloper Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.

To debug on a real device:

  1. On iOS - open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
  2. On Android, if you're running Android 5.0+ device connected via USB you can use adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

Custom JavaScript debugger #

To use a custom JavaScript debugger define the REACT_DEBUGGER environment variable to a command that will start your custom debugger. That variable will be read from the Packager process. If that environment variable is set, selecting Debug JS Remotely from the developer menu will execute that command instead of opening Chrome. The exact command to be executed is the contents of the REACT_DEBUGGER environment variable followed by the space separated paths of all project roots (e.g. 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 end up being executed). Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.

Live Reload #

This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option:

  1. On iOS, select Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.
  2. On Android, launch dev menu, go to Dev Settings and select Auto reload on JS change option

FPS (Frames per Second) Monitor #

On 0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/dimensions.html b/docs/dimensions.html index 821a862937e..f2ec17d21af 100644 --- a/docs/dimensions.html +++ b/docs/dimensions.html @@ -1,5 +1,5 @@ -Dimensions – React Native | A framework for building native apps using React

Dimensions #

Edit on GitHub

Methods #

static set(dims: {[key:string]: any}) #

This should only be called from native code by sending the -didUpdateDimensions event.

@param {object} dims Simple string-keyed object of dimensions to set

static get(dim: string) #

Initial dimensions are set before runApplication is called so they should +Dimensions – React Native | A framework for building native apps using React

Dimensions #

Edit on GitHub

Methods #

static set(dims) #

This should only be called from native code by sending the +didUpdateDimensions event.

@param {object} dims Simple string-keyed object of dimensions to set

static get(dim) #

Initial dimensions are set before runApplication is called so they should be available before any other require's are run, but may be updated later.

Note: Although dimensions are available immediately, they may change (e.g due to device rotation) so any rendering logic or styles that depend on these constants should try to call this function on every render, rather @@ -21,6 +21,6 @@ setting a value in a StyleSheet).

Example: var {height, apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/direct-manipulation.html b/docs/direct-manipulation.html index fa854ac7833..3b71320cdec 100644 --- a/docs/direct-manipulation.html +++ b/docs/direct-manipulation.html @@ -1,4 +1,4 @@ -Direct Manipulation – React Native | A framework for building native apps using React

Direct Manipulation #

Edit on GitHub

It is sometimes necessary to make changes directly to a component +Direct Manipulation – React Native | A framework for building native apps using React

Direct Manipulation #

Edit on GitHub

It is sometimes necessary to make changes directly to a component without using state/props to trigger a re-render of the entire subtree. When using React in the browser for example, you sometimes need to directly modify a DOM node, and the same is true for views in mobile @@ -10,7 +10,7 @@ hierarchy and reconciling many views. setNativeProps is imperative and stores state in the native layer (DOM, UIView, etc.) and not within your React components, which makes your code more difficult to reason about. Before you use it, try to solve your problem with setState -and shouldComponentUpdate.

setNativeProps with TouchableOpacity #

TouchableOpacity +and shouldComponentUpdate.

setNativeProps with TouchableOpacity #

TouchableOpacity uses setNativeProps internally to update the opacity of its child component:

setOpacityTo: function(value) { // Redacted: animation related code @@ -146,6 +146,6 @@ use setState instead of setNativeProps.

\ No newline at end of file diff --git a/docs/drawerlayoutandroid.html b/docs/drawerlayoutandroid.html index 766820dab03..843899df4b5 100644 --- a/docs/drawerlayoutandroid.html +++ b/docs/drawerlayoutandroid.html @@ -1,4 +1,4 @@ -DrawerLayoutAndroid – React Native | A framework for building native apps using React

DrawerLayoutAndroid #

Edit on GitHub

React component that wraps the platform DrawerLayout (Android only). The +DrawerLayoutAndroid – React Native | A framework for building native apps using React

DrawerLayoutAndroid #

Edit on GitHub

React component that wraps the platform DrawerLayout (Android only). The Drawer (typically used for navigation) is rendered with renderNavigationView and direct children are the main view (where your content goes). The navigation view is initially not visible on the screen, but can be pulled in from the @@ -20,7 +20,11 @@ be set by the drawerWidth prop.

Example:

/View> </DrawerLayoutAndroid> ); -},

Props #

drawerLockMode enum('unlocked', 'locked-closed', 'locked-open') #

Specifies the lock mode of the drawer. The drawer can be locked in 3 states: +},

Props #

drawerBackgroundColor color #

Specifies the background color of the drawer. The default value is white. +If you want to set the opacity of the drawer, use rgba. Example:

return ( + <DrawerLayoutAndroid drawerBackgroundColor="rgba(0,0,0,0.5)"> + </DrawerLayoutAndroid> +);

drawerLockMode enum('unlocked', 'locked-closed', 'locked-open') #

Specifies the lock mode of the drawer. The drawer can be locked in 3 states: - unlocked (default), meaning that the drawer will respond (open/close) to touch gestures. - locked-closed, meaning that the drawer will stay closed and not respond to gestures. - locked-open, meaning that the drawer will stay opened and not respond to gestures. @@ -33,7 +37,7 @@ from the edge of the window.

renderNavigationView function #

The navigation view that will be rendered to the side of the screen and can be pulled in.

statusBarBackgroundColor color #

Make the drawer take the entire screen and draw the background of the status bar to allow it to open over the status bar. It will only have an -effect on API 21+.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/embedded-app-android.html b/docs/embedded-app-android.html index c74425f6215..40e67ec04c5 100644 --- a/docs/embedded-app-android.html +++ b/docs/embedded-app-android.html @@ -1,4 +1,4 @@ -Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps #

Edit on GitHub

Since React makes no assumptions about the rest of your technology stack, it's easily embeddable within an existing non-React Native app.

Requirements #

  • an existing, gradle-based Android app
  • Node.js, see Getting Started for setup instructions

Prepare your app #

In your app's build.gradle file add the React Native dependency:

compile 'com.facebook.react:react-native:0.20.+'

You can find the latest version of the react-native library on Maven Central. Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { +Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps #

Edit on GitHub

Since React makes no assumptions about the rest of your technology stack, it's easily embeddable within an existing non-React Native app.

Requirements #

  • an existing, gradle-based Android app
  • Node.js, see Getting Started for setup instructions

Prepare your app #

In your app's build.gradle file add the React Native dependency:

compile 'com.facebook.react:react-native:0.20.+'

You can find the latest version of the react-native library on Maven Central. Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactRootView mReactRootView; private ReactInstanceManager mReactInstanceManager; @@ -101,6 +101,6 @@ React.AppRegistry \ No newline at end of file diff --git a/docs/embedded-app-ios.html b/docs/embedded-app-ios.html index 3cf7feef85b..c9ba6004184 100644 --- a/docs/embedded-app-ios.html +++ b/docs/embedded-app-ios.html @@ -1,4 +1,4 @@ -Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps #

Edit on GitHub

Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.

Requirements #

  • CocoaPodsgem install cocoapods
  • Node.js
    • Install nvm with its setup instructions here. 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.
  • Install the react-native package from npm by running the following command in the root directory of your project:
    • npm install react-native

At this point you should have the React Native package installed under a directory named node_modules as a sibling to your .xcodeproj file.

Install React Native Using CocoaPods #

CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't installed CocoaPods yet, check out this tutorial.

When you are ready to work with CocoaPods, add the following lines to Podfile. If you don't have one, then create it under the root directory of your project.

# Depending on how your project is organized, your node_modules directory may be +Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps #

Edit on GitHub

Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.

Requirements #

  • CocoaPodsgem install cocoapods
  • Node.js
    • Install nvm with its setup instructions here. 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.
  • Install the react-native package from npm by running the following command in the root directory of your project:
    • npm install react-native

At this point you should have the React Native package installed under a directory named node_modules as a sibling to your .xcodeproj file.

Install React Native Using CocoaPods #

CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't installed CocoaPods yet, check out this tutorial.

When you are ready to work with CocoaPods, add the following lines to Podfile. If you don't have one, then create it under the root directory of your project.

# Depending on how your project is organized, your node_modules directory may be # somewhere else; tell CocoaPods where you've installed react-native from npm pod 'React', :path => './node_modules/react-native', :subspecs => [ 'Core', @@ -96,6 +96,6 @@ class ReactView \ No newline at end of file diff --git a/docs/flexbox.html b/docs/flexbox.html index 8ea3f98cb2d..7040544e39c 100644 --- a/docs/flexbox.html +++ b/docs/flexbox.html @@ -1,4 +1,4 @@ -Flexbox – React Native | A framework for building native apps using React

Flexbox #

Edit on GitHub

Props #

alignItems enum('flex-start', 'flex-end', 'center', 'stretch') #

alignSelf enum('auto', 'flex-start', 'flex-end', 'center', 'stretch') #

borderBottomWidth number #

borderLeftWidth number #

borderRightWidth number #

borderTopWidth number #

borderWidth number #

bottom number #

flex number #

flexDirection enum('row', 'column') #

flexWrap enum('wrap', 'nowrap') #

height number #

justifyContent enum('flex-start', 'flex-end', 'center', 'space-between', 'space-around') #

left number #

margin number #

marginBottom number #

marginHorizontal number #

marginLeft number #

marginRight number #

marginTop number #

marginVertical number #

padding number #

paddingBottom number #

paddingHorizontal number #

paddingLeft number #

paddingRight number #

paddingTop number #

paddingVertical number #

position enum('absolute', 'relative') #

right number #

top number #

width number #

© 2016 Facebook Inc.

Flexbox #

Edit on GitHub

Props #

alignItems enum('flex-start', 'flex-end', 'center', 'stretch') #

alignSelf enum('auto', 'flex-start', 'flex-end', 'center', 'stretch') #

borderBottomWidth number #

borderLeftWidth number #

borderRightWidth number #

borderTopWidth number #

borderWidth number #

bottom number #

flex number #

flexDirection enum('row', 'column') #

flexWrap enum('wrap', 'nowrap') #

height number #

justifyContent enum('flex-start', 'flex-end', 'center', 'space-between', 'space-around') #

left number #

margin number #

marginBottom number #

marginHorizontal number #

marginLeft number #

marginRight number #

marginTop number #

marginVertical number #

padding number #

paddingBottom number #

paddingHorizontal number #

paddingLeft number #

paddingRight number #

paddingTop number #

paddingVertical number #

position enum('absolute', 'relative') #

right number #

top number #

width number #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/geolocation.html b/docs/geolocation.html index 39e831dbe5a..5998bbb280a 100644 --- a/docs/geolocation.html +++ b/docs/geolocation.html @@ -1,19 +1,22 @@ -Geolocation – React Native | A framework for building native apps using React

Geolocation #

Edit on GitHub

The Geolocation API follows the web spec: +Geolocation – React Native | A framework for building native apps using React

Geolocation #

Edit on GitHub

The Geolocation API follows the web spec: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation

iOS #

You need to include the NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation. Geolocation is enabled by default when you create a project with react-native init.

Android #

To request access to location, you need to add the following line to your -app's AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Methods #

static getCurrentPosition(geo_success: Function, geo_error?: Function, geo_options?: GeoOptions) #

Invokes the success callback once with the latest location info. Supported -options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)

static watchPosition(success: Function, error?: Function, options?: GeoOptions) #

Invokes the success callback whenever the location changes. Supported -options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m)

static clearWatch(watchID: number) #

static stopObserving() #

Examples #

Edit on GitHub
/* eslint no-console: 0 */ +app's AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Methods #

static getCurrentPosition(geo_success, geo_error?, geo_options?) #

Invokes the success callback once with the latest location info. Supported +options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool) +On Android, this can return almost immediately if the location is cached or +request an update, which might take a while.

static watchPosition(success, error?, options?) #

Invokes the success callback whenever the location changes. Supported +options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m)

static clearWatch(watchID) #

static stopObserving() #

Examples #

Edit on GitHub
/* eslint no-console: 0 */ 'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, Text, View, -} = React; +} = ReactNative; exports.framework = 'React'; exports.title = 'Geolocation'; @@ -93,6 +96,6 @@ exports.examples \ No newline at end of file diff --git a/docs/gesture-responder-system.html b/docs/gesture-responder-system.html index 6f28064397a..258b02daf18 100644 --- a/docs/gesture-responder-system.html +++ b/docs/gesture-responder-system.html @@ -1,4 +1,4 @@ -Gesture Responder System – React Native | A framework for building native apps using React

Gesture Responder System #

Edit on GitHub

Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.

The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.

Best Practices #

Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:

  • Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture
  • Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away

These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.

TouchableHighlight and Touchable* #

The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.

Responder Lifecycle #

A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:

  • View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?
  • View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?

If the View returns true and attempts to become the responder, one of the following will happen:

  • View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happening
  • View.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release it

If the view is responding, the following handlers can be called:

  • View.props.onResponderMove: (evt) => {} - The user is moving their finger
  • View.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"
  • View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows release
  • View.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)

evt is a synthetic touch event with the following form:

  • nativeEvent
    • changedTouches - Array of all touch events that have changed since the last event
    • identifier - The ID of the touch
    • locationX - The X position of the touch, relative to the element
    • locationY - The Y position of the touch, relative to the element
    • pageX - The X position of the touch, relative to the root element
    • pageY - The Y position of the touch, relative to the root element
    • target - The node id of the element receiving the touch event
    • timestamp - A time identifier for the touch, useful for velocity calculation
    • touches - Array of all current touches on the screen

Capture ShouldSet Handlers #

onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.

However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.

  • View.props.onStartShouldSetResponderCapture: (evt) => true,
  • View.props.onMoveShouldSetResponderCapture: (evt) => true,

PanResponder #

For higher-level gesture interpretation, check out PanResponder.

© 2016 Facebook Inc.

Gesture Responder System #

Edit on GitHub

Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.

The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.

Best Practices #

Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:

  • Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture
  • Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away

These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.

TouchableHighlight and Touchable* #

The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.

Responder Lifecycle #

A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:

  • View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?
  • View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?

If the View returns true and attempts to become the responder, one of the following will happen:

  • View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happening
  • View.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release it

If the view is responding, the following handlers can be called:

  • View.props.onResponderMove: (evt) => {} - The user is moving their finger
  • View.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"
  • View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows release
  • View.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)

evt is a synthetic touch event with the following form:

  • nativeEvent
    • changedTouches - Array of all touch events that have changed since the last event
    • identifier - The ID of the touch
    • locationX - The X position of the touch, relative to the element
    • locationY - The Y position of the touch, relative to the element
    • pageX - The X position of the touch, relative to the root element
    • pageY - The Y position of the touch, relative to the root element
    • target - The node id of the element receiving the touch event
    • timestamp - A time identifier for the touch, useful for velocity calculation
    • touches - Array of all current touches on the screen

Capture ShouldSet Handlers #

onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.

However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.

  • View.props.onStartShouldSetResponderCapture: (evt) => true,
  • View.props.onMoveShouldSetResponderCapture: (evt) => true,

PanResponder #

For higher-level gesture interpretation, check out PanResponder.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/getting-started-linux.html b/docs/getting-started-linux.html index f2a5474cde3..74946a4f0b8 100644 --- a/docs/getting-started-linux.html +++ b/docs/getting-started-linux.html @@ -1,16 +1,17 @@ -Getting Started on Linux – React Native | A framework for building native apps using React

Getting Started on Linux #

Edit on GitHub

This guide is essentially a beginner-friendly version of the Getting Started 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 for details.

Installing NodeJS #

The first thing you need to do is to install NodeJS, a popular Javascript implementation.

Fire up the Terminal and paste the following commands to install NodeJS from the NodeSource repository:

sudo apt-get install -y build-essential +Getting Started on Linux – React Native | A framework for building native apps using React

Getting Started on Linux #

Edit on GitHub

This guide is essentially a beginner-friendly version of the Getting Started 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 for details.

Installing NodeJS #

The first thing you need to do is to install NodeJS, a popular Javascript implementation.

Fire up the Terminal and paste 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

NOTE: The above instructions are for Ubuntu. If you're on a different distro, please follow the instructions on the NodeJS website.

Installing Watchman #

watchman 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.

Paste the following into your terminal to compile watchman from source and install it:

git clone https://github.com/facebook/watchman.git +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.

Installing Watchman #

watchman 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.

Paste the following into your terminal to compile watchman from source and install it:

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

Installing Flow #

Flow is a static type checker for JavaScript. To install it, paste the following in the terminal:

sudo 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:

$ lsusb +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, paste the following in the terminal:

sudo 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:

$ 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 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 @@ -20,7 +21,7 @@ Bus 002 Device 001< 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:

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.

List of devices attached +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:

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.

List of devices attached TA9300GLMK device

For more information, please see the docs for running an Android app on your device.

Next Steps #

Your Android device and your tools are all ready to go. You can now follow the instructions in the Quick Start guide to install React Native and start your first project.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/getting-started.html b/docs/getting-started.html index 972d210f7cf..21e03d5c0be 100644 --- a/docs/getting-started.html +++ b/docs/getting-started.html @@ -1,4 +1,4 @@ -Getting Started – React Native | A framework for building native apps using React

Getting Started #

Edit on GitHub

Requirements #

  1. OS X - This guide assumes OS X which is needed for iOS development.
  2. Homebrew is the recommended way to install Watchman and Flow.
  3. Install Node.js 4.0 or newer.
    • Install nvm with its setup instructions here. 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?
  4. brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.
  5. brew install flow, if you want to use flow.

We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.

iOS Setup #

Xcode 7.0 or higher is required. It can be installed from the App Store.

Android Setup #

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 for instructions on how to set up your Android environment.

NOTE: There is experimental Windows and Linux support for Android development.

Quick start #

Install the React Native command line tools:

$ npm install -g react-native-cli

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

Create a React Native project:

$ react-native init AwesomeProject

To run the iOS app:

  • $ 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.
  • 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.

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 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.

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

If you run into any issues getting started, see the troubleshooting page.

Adding Android to an existing React Native project #

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:

  1. Update the react-native dependency in your package.json file to the latest version
  2. $ npm install
  3. $ react-native android
© 2016 Facebook Inc.

Getting Started #

Edit on GitHub

Requirements #

  1. OS X - This guide assumes OS X which is needed for iOS development.
  2. Homebrew is the recommended way to install Watchman and Flow.
  3. Install Node.js 4.0 or newer.
    • Install nvm with its setup instructions here. 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?
  4. brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.
  5. brew install flow, if you want to use flow.

We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.

iOS Setup #

Xcode 7.0 or higher is required. It can be installed from the App Store.

Android Setup #

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 for instructions on how to set up your Android environment.

NOTE: There is experimental Windows and Linux support for Android development.

Quick start #

Install the React Native command line tools:

$ npm install -g react-native-cli

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

Create a React Native project:

$ react-native init AwesomeProject

To run the iOS app:

  • $ 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.
  • 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.

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!
  • 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.

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

If you run into any issues getting started, see the troubleshooting page.

Adding Android to an existing React Native project #

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:

  1. Update the react-native dependency in your package.json file to the latest version
  2. $ npm install
  3. $ react-native android
© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/image.html b/docs/image.html index 94f2ec2a53e..88f2d3e94aa 100644 --- a/docs/image.html +++ b/docs/image.html @@ -1,4 +1,4 @@ -Image – React Native | A framework for building native apps using React

Image #

Edit on GitHub

A React component for displaying different types of images, +Image – React Native | A framework for building native apps using React

Image #

Edit on GitHub

A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll.

Example usage:

renderImages: function() { return ( @@ -22,7 +22,7 @@ so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).

'stretch': Scale width and height independently, This may change the aspect ratio of the src.

source {uri: string}, number #

uri is a string representing the resource identifier for the image, which could be an http address, a local file path, or the name of a static image -resource (which should be wrapped in the require('./path/to/image.png') function).

style style #

backfaceVisibility enum('visible', 'hidden')
backgroundColor color
borderColor color
borderRadius number
borderWidth number
opacity number
overflow enum('visible', 'hidden')
resizeMode Object.keys(ImageResizeMode)
androidoverlayColor string

When the image has rounded corners, specifying an overlayColor will +resource (which should be wrapped in the require('./path/to/image.png') function).

style style #

backfaceVisibility enum('visible', 'hidden')
backgroundColor color
borderBottomLeftRadius number
borderBottomRightRadius number
borderColor color
borderRadius number
borderTopLeftRadius number
borderTopRightRadius number
borderWidth number
opacity number
overflow enum('visible', 'hidden')
resizeMode Object.keys(ImageResizeMode)
androidoverlayColor string

When the image has rounded corners, specifying an overlayColor will cause the remaining space in the corners to be filled with a solid color. This is useful in cases which are not supported by the Android implementation of rounded corners: @@ -37,9 +37,17 @@ the image.

iosdefaultSource {uri: string}, number #

A static image to display while loading the image source.

iosonError function #

Invoked on load error with {nativeEvent: {error}}

iosonProgress function #

Invoked on download progress with {nativeEvent: {loaded, total}}

Examples #

Edit on GitHub
'use strict'; +Apple documentation

iosdefaultSource {uri: string}, number #

A static image to display while loading the image source.

iosonError function #

Invoked on load error with {nativeEvent: {error}}

iosonProgress function #

Invoked on download progress with {nativeEvent: {loaded, total}}

Methods #

static getSize(uri: string, success: (width: number, height: number) => void, failure: (error: any) => void) #

Retrieve the width and height (in pixels) of an image prior to displaying it. +This method can fail if the image cannot be found, or fails to download.

In order to retrieve the image dimensions, the image may first need to be +loaded or downloaded, after which it will be cached. This means that in +principle you could use this method to preload images, however it is not +optimized for that purpose, and may in future be implemented in a way that +does not fully load/download the image data. A proper, supported way to +preload images will be provided as a separate API.

static prefetch(url: string) #

Prefetches a remote image for later use by downloading it to the disk +cache

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Image, Platform, @@ -47,16 +55,19 @@ rounded buttons, shadows, and other resizable assets. More info on Text, View, ActivityIndicatorIOS -} = React; +} = ReactNative; var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg=='; var ImageCapInsetsExample = require('./ImageCapInsetsExample'); +const IMAGE_PREFETCH_URL = 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1&t=' + Date.now(); +var prefetchTask = Image.prefetch(IMAGE_PREFETCH_URL); var NetworkImageCallbackExample = React.createClass({ getInitialState: function() { return { events: [], + startLoadPrefetched: false, mountTime: new Date(), }; }, @@ -75,9 +86,26 @@ rounded buttons, shadows, and other resizable assets. More info on style={[styles.base, {overflow: 'visible'}]} onLoadStart={() => this._loadEventFired(`✔ onLoadStart (+${new Date() - mountTime}ms)`)} onLoad={() => this._loadEventFired(`✔ onLoad (+${new Date() - mountTime}ms)`)} - onLoadEnd={() => this._loadEventFired(`✔ onLoadEnd (+${new Date() - mountTime}ms)`)} + onLoadEnd={() => { + this._loadEventFired(`✔ onLoadEnd (+${new Date() - mountTime}ms)`); + this.setState({startLoadPrefetched: true}, () => { + prefetchTask.then(() => { + this._loadEventFired(`✔ Prefetch OK (+${new Date() - mountTime}ms)`); + }, error => { + this._loadEventFired(`✘ Prefetch failed (+${new Date() - mountTime}ms)`); + }); + }); + }} /> - + {this.state.startLoadPrefetched ? + <Image + source={this.props.prefetchedSource} + style={[styles.base, {overflow: 'visible'}]} + onLoadStart={() => this._loadEventFired(`✔ (prefetched) onLoadStart (+${new Date() - mountTime}ms)`)} + onLoad={() => this._loadEventFired(`✔ (prefetched) onLoad (+${new Date() - mountTime}ms)`)} + onLoadEnd={() => this._loadEventFired(`✔ (prefetched) onLoadEnd (+${new Date() - mountTime}ms)`)} + /> + : null} <Text style={{marginTop: 20}}> {this.state.events.join('\n')} </Text> @@ -190,7 +218,8 @@ exports.examples : 'Image Loading Events', render: function() { return ( - <NetworkImageCallbackExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}}/> + <NetworkImageCallbackExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1&t=' + Date.now()}} + prefetchedSource={{uri: IMAGE_PREFETCH_URL}}/> ); }, }, @@ -579,6 +608,6 @@ exports.examples \ No newline at end of file diff --git a/docs/images.html b/docs/images.html index 4eb1f1536c8..50114e2673c 100644 --- a/docs/images.html +++ b/docs/images.html @@ -1,4 +1,4 @@ -Images – React Native | A framework for building native apps using React

Images #

Edit on GitHub

Static Image Resources #

As of 0.14 release, React Native provides a unified way of managing images in your iOS and Android apps. To add a static image to your app, place it somewhere in your source code tree and reference it like this:

<Image source={require('./my-icon.png')} />

The image name is resolved the same way JS modules are resolved. In the example above the packager will look for my-icon.png in the same folder as the component that requires it. Also if you have my-icon.ios.png and my-icon.android.png, the packager will pick the file depending on the platform you are running on.

You can also use @2x, @3x, etc. suffix in the file name to provide images for different screen densities. For example, if you have the following file structure:

. +Images – React Native | A framework for building native apps using React

Images #

Edit on GitHub

Static Image Resources #

As of 0.14 release, React Native provides a unified way of managing images in your iOS and Android apps. To add a static image to your app, place it somewhere in your source code tree and reference it like this:

<Image source={require('./my-icon.png')} />

The image name is resolved the same way JS modules are resolved. In the example above the packager will look for my-icon.png in the same folder as the component that requires it. Also if you have my-icon.ios.png and my-icon.android.png, the packager will pick the file depending on the platform you are running on.

You can also use @2x, @3x, etc. suffix in the file name to provide images for different screen densities. For example, if you have the following file structure:

. ├── button.js └── img ├── check@2x.png @@ -37,6 +37,6 @@ using local resources that are outside of Images.xcassets.

< apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/intentandroid.html b/docs/intentandroid.html index 300e1b2095c..d6ab72d67d4 100644 --- a/docs/intentandroid.html +++ b/docs/intentandroid.html @@ -1,4 +1,4 @@ -IntentAndroid – React Native | A framework for building native apps using React

IntentAndroid #

Edit on GitHub

NOTE: IntentAndroid is being deprecated. Use Linking instead.

IntentAndroid gives you a general interface to handle external links.

Basic Usage #

Handling deep links #

If your app was launched from an external url registered to your app you can +IntentAndroid – React Native | A framework for building native apps using React

IntentAndroid #

Edit on GitHub

NOTE: IntentAndroid is being deprecated. Use Linking instead.

IntentAndroid gives you a general interface to handle external links.

Basic Usage #

Handling deep links #

If your app was launched from an external url registered to your app you can access and handle it from any component you want with

componentDidMount() { var url = IntentAndroid.getInitialURL(url => { if (url) { @@ -25,11 +25,11 @@ More Info: } else { IntentAndroid.openURL(url); } -});

Methods #

static openURL(url: string) #

Starts a corresponding external activity for the given URL.

For example, if the URL is "https://www.facebook.com", the system browser will be opened, +});

Methods #

static openURL(url) #

Starts a corresponding external activity for the given URL.

For example, if the URL is "https://www.facebook.com", the system browser will be opened, or the "choose application" dialog will be shown.

You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, or any other URL that can be opened with {@code Intent.ACTION_VIEW}.

NOTE: This method will fail if the system doesn't know how to open the specified URL. -If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

@deprecated

static canOpenURL(url: string, callback: Function) #

Determine whether or not an installed app can handle a given URL.

You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, -or any other URL that can be opened with {@code Intent.ACTION_VIEW}.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

@param URL the URL to open

@deprecated

static getInitialURL(callback: Function) #

If the app launch was triggered by an app link with {@code Intent.ACTION_VIEW}, +If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

@deprecated

static canOpenURL(url, callback) #

Determine whether or not an installed app can handle a given URL.

You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, +or any other URL that can be opened with {@code Intent.ACTION_VIEW}.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

@param URL the URL to open

@deprecated

static getInitialURL(callback) #

If the app launch was triggered by an app link with {@code Intent.ACTION_VIEW}, it will give the link url, otherwise it will give null

Refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents

@deprecated

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/interactionmanager.html b/docs/interactionmanager.html index 450d79639a1..a5036d7fe92 100644 --- a/docs/interactionmanager.html +++ b/docs/interactionmanager.html @@ -1,4 +1,4 @@ -InteractionManager – React Native | A framework for building native apps using React

InteractionManager #

Edit on GitHub

InteractionManager allows long-running work to be scheduled after any +InteractionManager – React Native | A framework for building native apps using React

InteractionManager #

Edit on GitHub

InteractionManager allows long-running work to be scheduled after any interactions/animations have completed. In particular, this allows JavaScript animations to run smoothly.

Applications can schedule tasks to run after interactions with the following:

InteractionManager.runAfterInteractions(() => { // ...long-running synchronous task... @@ -20,7 +20,7 @@ earlier.

By default, queued tasks are executed together in a loop in one tasks will only be executed until the deadline (in terms of js event loop run time) approaches, at which point execution will yield via setTimeout, allowing events such as touches to start interactions and block queued tasks -from executing, making apps more responsive.

Methods #

static runAfterInteractions(task: Task) #

Schedule a function to run after all interactions have completed.

static createInteractionHandle() #

Notify manager that an interaction has started.

static clearInteractionHandle(handle: Handle) #

Notify manager that an interaction has completed.

static setDeadline(deadline: number) #

A positive number will use setTimeout to schedule any tasks after the +from executing, making apps more responsive.

Methods #

static runAfterInteractions(task) #

Schedule a function to run after all interactions have completed.

static createInteractionHandle() #

Notify manager that an interaction has started.

static clearInteractionHandle(handle) #

Notify manager that an interaction has completed.

static setDeadline(deadline) #

A positive number will use setTimeout to schedule any tasks after the eventLoopRunningTime hits the deadline value, otherwise all tasks will be executed in one setImmediate batch (default).

Properties #

Events: CallExpression #

addListener: CallExpression #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/javascript-environment.html b/docs/javascript-environment.html index c7e039bcdb2..a3e889e44bd 100644 --- a/docs/javascript-environment.html +++ b/docs/javascript-environment.html @@ -1,4 +1,4 @@ -JavaScript Environment – React Native | A framework for building native apps using React

JavaScript Environment #

Edit on GitHub

JavaScript Runtime #

When using React Native, you're going to be running your JavaScript code in two environments:

  • On iOS simulators and devices, Android emulators and devices React Native uses JavaScriptCore which is the JavaScript engine that powers Safari. On iOS JSC doesn't use JIT due to the absence of writable executable memory in iOS apps.
  • When using Chrome debugging, it runs all the JavaScript code within Chrome itself and communicates with native code via WebSocket. So you are using V8.

While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.

JavaScript Syntax Transformers #

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. Check Babel documentation on its supported transformations for more details.

Here's a full list of React Native's enabled transformations.

ES5

  • Reserved Words: promise.catch(function() { });

ES6

ES7

Specific

  • JSX: <View style={{color: 'red'}} />
  • Flow: function foo(x: ?number): string {}

Polyfills #

Many standards functions are also available on all the supported JavaScript runtimes.

Browser

ES6

ES7

Specific

  • __DEV__
© 2016 Facebook Inc.

JavaScript Environment #

Edit on GitHub

JavaScript Runtime #

When using React Native, you're going to be running your JavaScript code in two environments:

  • On iOS simulators and devices, Android emulators and devices React Native uses JavaScriptCore which is the JavaScript engine that powers Safari. On iOS JSC doesn't use JIT due to the absence of writable executable memory in iOS apps.
  • When using Chrome debugging, it runs all the JavaScript code within Chrome itself and communicates with native code via WebSocket. So you are using V8.

While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.

JavaScript Syntax Transformers #

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. Check Babel documentation on its supported transformations for more details.

Here's a full list of React Native's enabled transformations.

ES5

  • Reserved Words: promise.catch(function() { });

ES6

ES7

Specific

  • JSX: <View style={{color: 'red'}} />
  • Flow: function foo(x: ?number): string {}

Polyfills #

Many standards functions are also available on all the supported JavaScript runtimes.

Browser

ES6

ES7

Specific

  • __DEV__
© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/known-issues.html b/docs/known-issues.html index 778a6834848..7bcfe4bcea2 100644 --- a/docs/known-issues.html +++ b/docs/known-issues.html @@ -1,4 +1,4 @@ -Known Issues – React Native | A framework for building native apps using React

Known Issues #

Edit on GitHub

Devtools "React" Tab Does Not Work #

It's currently not possible to use the "React" tab in the devtools to inspect app widgets. This is due to a change in how the application scripts are evaluated in the devtools plugin; they are now run inside a Web Worker, and the plugin is unaware of this and so unable to communicate properly with React Native.

However, you can still use the Console feature of the devtools, and debugging JavaScript with breakpoints works too. To use the console, make sure to select the ⚙debuggerWorker.js entry in the devtools dropdown that by default is set to <top frame>.

Missing Android Modules and Views #

The work on React Native for Android started later than React Native for iOS. Most views and modules are now available on Android, with the following exceptions:

Views #

  • Maps - Please use Leland Richardson's react-native-maps as it is more feature-complete than our internal implementation.

Modules #

Some props are only supported on one platform #

There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with @platform in JS docs and have a small badge next to them on the website. See e.g. Image.

Platform parity #

There are known cases where the APIs could be made more consistent across iOS and Android:

  • <ViewPagerAndroid> and <ScrollView pagingEnabled={true}> on iOS do a similar thing. We might want to unify them to <ViewPager>.
  • ActivityIndicator could render a native spinning indicator on both platforms (currently this is done using ActivityIndicatorIOS on iOS and ProgressBarAndroid on Android).
  • ProgressBar could render a horizontal progress bar on both platforms (on iOS this is ProgressViewIOS, on Android it's ProgressBarAndroid).

The overflow style property defaults to hidden and cannot be changed on Android #

This is a result of how Android rendering works. This feature is not being worked on as it would be a significant undertaking and there are many more important tasks.

Another issue with overflow: 'hidden' on Android: a view is not clipped by the parent's borderRadius even if the parent has overflow: 'hidden' enabled – the corners of the inner view will be visible outside of the rounded corners. This is only on Android; it works as expected on iOS. See a demo of the bug and the corresponding issue.

View shadows #

The shadow* view styles apply on iOS, and the elevation view prop is available on Android. Setting elevation on Android is equivalent to using the native elevation API, and has the same limitations (most significantly, it only works on Android 5.0+). Setting elevation on Android also affects the z-order for overlapping views.

Android M permissions #

The open source version of React Native doesn't yet support the Android M permission model.

Layout-only nodes on Android #

An optimization feature of the Android version of React Native is for views which only contribute to the layout to not have a native view, only their layout properties are propagated to their children views. This optimization is to provide stability in deep view hierarchies for React Native and is therefore enabled by default. Should you depend on a view being present or internal tests incorrectly detect a view is layout only it will be necessary to turn off this behavior. To do this, set collapsable to false as in this example:

<View collapsable={false}> +Known Issues – React Native | A framework for building native apps using React

Known Issues #

Edit on GitHub

Devtools "React" Tab Does Not Work #

It's currently not possible to use the "React" tab in the devtools to inspect app widgets. This is due to a change in how the application scripts are evaluated in the devtools plugin; they are now run inside a Web Worker, and the plugin is unaware of this and so unable to communicate properly with React Native.

However, you can still use the Console feature of the devtools, and debugging JavaScript with breakpoints works too. To use the console, make sure to select the ⚙debuggerWorker.js entry in the devtools dropdown that by default is set to <top frame>.

Missing Android Modules and Views #

The work on React Native for Android started later than React Native for iOS. Most views and modules are now available on Android, with the following exceptions:

Views #

  • Maps - Please use Leland Richardson's react-native-maps as it is more feature-complete than our internal implementation.

Modules #

Some props are only supported on one platform #

There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with @platform in JS docs and have a small badge next to them on the website. See e.g. Image.

Platform parity #

There are known cases where the APIs could be made more consistent across iOS and Android:

  • <ViewPagerAndroid> and <ScrollView pagingEnabled={true}> on iOS do a similar thing. We might want to unify them to <ViewPager>.
  • ActivityIndicator could render a native spinning indicator on both platforms (currently this is done using ActivityIndicatorIOS on iOS and ProgressBarAndroid on Android).
  • ProgressBar could render a horizontal progress bar on both platforms (on iOS this is ProgressViewIOS, on Android it's ProgressBarAndroid).

The overflow style property defaults to hidden and cannot be changed on Android #

This is a result of how Android rendering works. This feature is not being worked on as it would be a significant undertaking and there are many more important tasks.

Another issue with overflow: 'hidden' on Android: a view is not clipped by the parent's borderRadius even if the parent has overflow: 'hidden' enabled – the corners of the inner view will be visible outside of the rounded corners. This is only on Android; it works as expected on iOS. See a demo of the bug and the corresponding issue.

View shadows #

The shadow* view styles apply on iOS, and the elevation view prop is available on Android. Setting elevation on Android is equivalent to using the native elevation API, and has the same limitations (most significantly, it only works on Android 5.0+). Setting elevation on Android also affects the z-order for overlapping views.

Android M permissions #

The open source version of React Native doesn't yet support the Android M permission model.

Layout-only nodes on Android #

An optimization feature of the Android version of React Native is for views which only contribute to the layout to not have a native view, only their layout properties are propagated to their children views. This optimization is to provide stability in deep view hierarchies for React Native and is therefore enabled by default. Should you depend on a view being present or internal tests incorrectly detect a view is layout only it will be necessary to turn off this behavior. To do this, set collapsable to false as in this example:

<View collapsable={false}> ... </View>

Memory issues with PNG images #

React Native Android depends on Fresco for loading and displaying images. Currently we have disabled downsampling because it is experimental, so you may run into memory issues when loading large PNG images.

react-native init hangs #

Try running react-native init with --verbose and see #2797 for common causes.

Text Input Border #

The text input has by default a border at the bottom of its view. This border has its padding set by the background image provided by the system, and it cannot be changed. Solutions to avoid this is to either not set height explicitly, case in which the system will take care of displaying the border in the correct position, or to not display the border by setting underlineColorAndroid to transparent.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/layoutanimation.html b/docs/layoutanimation.html index 74709beb987..0b3ee78ace4 100644 --- a/docs/layoutanimation.html +++ b/docs/layoutanimation.html @@ -1,9 +1,9 @@ -LayoutAnimation – React Native | A framework for building native apps using React

LayoutAnimation #

Edit on GitHub

Automatically animates views to their new positions when the +LayoutAnimation – React Native | A framework for building native apps using React

LayoutAnimation #

Edit on GitHub

Automatically animates views to their new positions when the next layout happens.

A common way to use this API is to call LayoutAnimation.configureNext -before calling setState.

Methods #

static configureNext(config: Config, onAnimationDidEnd?: Function) #

Schedules an animation to happen on the next layout.

@param config Specifies animation properties:

  • duration in milliseconds
  • create, config for animating in new views (see Anim type)
  • update, config for animating views that have been updated +before calling setState.

Methods #

static configureNext(config, onAnimationDidEnd?) #

Schedules an animation to happen on the next layout.

@param config Specifies animation properties:

  • duration in milliseconds
  • create, config for animating in new views (see Anim type)
  • update, config for animating views that have been updated (see Anim type)

@param onAnimationDidEnd Called when the animation finished. Only supported on iOS. -@param onError Called on error. Only supported on iOS.

static create(duration: number, type, creationProp) #

Helper for creating a config for configureNext.

Properties #

Types: CallExpression #

Properties: CallExpression #

configChecker: CallExpression #

Presets: ObjectExpression #

easeInEaseOut: CallExpression #

linear: CallExpression #

spring: CallExpression #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/linking-libraries-ios.html b/docs/linking-libraries-ios.html index 24fd33e066d..4ed2da750ee 100644 --- a/docs/linking-libraries-ios.html +++ b/docs/linking-libraries-ios.html @@ -1,4 +1,4 @@ -Linking Libraries – React Native | A framework for building native apps using React

Linking Libraries #

Edit on GitHub

Not every app uses all the native capabilities, and including the code to support +Linking Libraries – React Native | A framework for building native apps using React

Linking Libraries #

Edit on GitHub

Not every app uses all the native capabilities, and including the code to support all those features would impact the binary size... But we still want to make it easy to add these features whenever you need them.

With that in mind we exposed many of these features as independent static libraries.

For most of the libs it will be as simple as dragging two files, sometimes a third step will be necessary, but no more than that.

All the libraries we ship with React Native live on the Libraries folder in @@ -35,6 +35,6 @@ example).

\ No newline at end of file diff --git a/docs/linking.html b/docs/linking.html index 6317a0c3068..00fe8090b71 100644 --- a/docs/linking.html +++ b/docs/linking.html @@ -1,4 +1,4 @@ -Linking – React Native | A framework for building native apps using React

Linking #

Edit on GitHub

Linking gives you a general interface to interact with both incoming +Linking – React Native | A framework for building native apps using React

Linking #

Edit on GitHub

Linking gives you a general interface to interact with both incoming and outgoing app links.

Basic Usage #

Handling deep links #

If your app was launched from an external url registered to your app you can access and handle it from any component you want with

componentDidMount() { var url = Linking.getInitialURL().then((url) => { @@ -39,21 +39,22 @@ execution you'll need to add the following lines to you *AppDelegate. } else { return Linking.openURL(url); } -}).catch(err => console.error('An error occurred', err));

Methods #

static addEventListener(type: string, handler: Function) #

Add a handler to Linking changes by listening to the url event type -and providing the handler

@platform ios

static removeEventListener(type: string, handler: Function) #

Remove a handler by passing the url event type and the handler

@platform ios

static openURL(url: string) #

Try to open the given url with any of the installed apps.

You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, +}).catch(err => console.error('An error occurred', err));

Methods #

static addEventListener(type, handler) #

Add a handler to Linking changes by listening to the url event type +and providing the handler

@platform ios

static removeEventListener(type, handler) #

Remove a handler by passing the url event type and the handler

@platform ios

static openURL(url) #

Try to open the given url with any of the installed apps.

You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, or any other URL that can be opened with the installed apps.

NOTE: This method will fail if the system doesn't know how to open the specified URL. -If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

static canOpenURL(url: string) #

Determine whether or not an installed app can handle a given URL.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key +If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

static canOpenURL(url) #

Determine whether or not an installed app can handle a given URL.

NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!

NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist.

@param URL the URL to open

static getInitialURL() #

If the app launch was triggered by an app link with, it will give the link url, otherwise it will give null

NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Linking, StyleSheet, Text, TouchableNativeFeedback, View, -} = React; +} = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); var OpenURLButton = React.createClass({ @@ -138,6 +139,6 @@ module.exports \ No newline at end of file diff --git a/docs/linkingios.html b/docs/linkingios.html index 9942a187ffc..3b0405f4893 100644 --- a/docs/linkingios.html +++ b/docs/linkingios.html @@ -1,4 +1,4 @@ -LinkingIOS – React Native | A framework for building native apps using React

LinkingIOS #

Edit on GitHub

NOTE: LinkingIOS is being deprecated. Use Linking instead.

LinkingIOS gives you a general interface to interact with both incoming +LinkingIOS – React Native | A framework for building native apps using React

LinkingIOS #

Edit on GitHub

NOTE: LinkingIOS is being deprecated. Use Linking instead.

LinkingIOS gives you a general interface to interact with both incoming and outgoing app links.

Basic Usage #

Handling deep links #

If your app was launched from an external url registered to your app you can access and handle it from any component you want with

componentDidMount() { var url = LinkingIOS.popInitialURL(); @@ -32,8 +32,8 @@ execution you'll need to add the following lines to you *AppDelegate. } else { LinkingIOS.openURL(url); } -});

Methods #

static addEventListener(type: string, handler: Function) #

Add a handler to LinkingIOS changes by listening to the url event type -and providing the handler

@deprecated

static removeEventListener(type: string, handler: Function) #

Remove a handler by passing the url event type and the handler

@deprecated

static openURL(url: string) #

Try to open the given url with any of the installed apps.

@deprecated

static canOpenURL(url: string, callback: Function) #

Determine whether or not an installed app can handle a given URL. +});

Methods #

static addEventListener(type, handler) #

Add a handler to LinkingIOS changes by listening to the url event type +and providing the handler

@deprecated

static removeEventListener(type, handler) #

Remove a handler by passing the url event type and the handler

@deprecated

static openURL(url) #

Try to open the given url with any of the installed apps.

@deprecated

static canOpenURL(url, callback) #

Determine whether or not an installed app can handle a given URL. The callback function will be called with bool supported as the only argument

NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist.

@deprecated

static popInitialURL() #

If the app launch was triggered by an app link, it will pop the link url, otherwise it will return null

@deprecated

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/linux-windows-support.html b/docs/linux-windows-support.html index 703c7ccd52b..46b9bf536cf 100644 --- a/docs/linux-windows-support.html +++ b/docs/linux-windows-support.html @@ -1,4 +1,4 @@ -Linux and Windows Support – React Native | A framework for building native apps using React

Linux and Windows Support #

Edit on GitHub

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 4.0 or newer. On Linux we recommend installing watchman, 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 +Linux and Windows Support – React Native | A framework for building native apps using React

Linux and Windows Support #

Edit on GitHub

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 4.0 or newer. On Linux we recommend installing watchman, 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 (under your node_modules/react-native/).

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/listview.html b/docs/listview.html index a95c6a42f65..1ab723aebc7 100644 --- a/docs/listview.html +++ b/docs/listview.html @@ -1,4 +1,4 @@ -ListView – React Native | A framework for building native apps using React

ListView #

Edit on GitHub

ListView - A core component designed for efficient display of vertically +ListView – React Native | A framework for building native apps using React

ListView #

Edit on GitHub

ListView - A core component designed for efficient display of vertically scrolling lists of changing data. The minimal API is to create a ListView.DataSource, populate it with a simple array of data blobs, and instantiate a ListView component with that data source and a renderRow @@ -66,9 +66,10 @@ pixels.

Methods #

getMetrics() #

Exports some data, e.g. for perf investigations or analytics.

scrollTo(...args) #

Scrolls to a given x, y offset, either immediately or with a smooth animation.

See ScrollView#scrollTo.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Image, ListView, @@ -77,7 +78,7 @@ with horizontal={true}.

, Text, View, -} = React; +} = ReactNative; var UIExplorerPage = require('./UIExplorerPage'); @@ -211,6 +212,6 @@ module.exports \ No newline at end of file diff --git a/docs/mapview.html b/docs/mapview.html index e938328ad10..92b6401c75b 100644 --- a/docs/mapview.html +++ b/docs/mapview.html @@ -1,4 +1,4 @@ -MapView – React Native | A framework for building native apps using React

MapView #

Edit on GitHub

Props #

onAnnotationPress function #

Deprecated. Use annotation onFocus and onBlur instead.

onRegionChange function #

Callback that is called continuously when the user is dragging the map.

onRegionChangeComplete function #

Callback that is called once, when the user is done moving the map.

pitchEnabled bool #

When this property is set to true and a valid camera is associated +MapView – React Native | A framework for building native apps using React

MapView #

Edit on GitHub

Props #

onAnnotationPress function #

Deprecated. Use annotation onFocus and onBlur instead.

onRegionChange function #

Callback that is called continuously when the user is dragging the map.

onRegionChangeComplete function #

Callback that is called once, when the user is done moving the map.

pitchEnabled bool #

When this property is set to true and a valid camera is associated with the map, the camera’s pitch angle is used to tilt the plane of the map. When this property is set to false, the camera’s pitch angle is ignored and the map is always displayed as if the user @@ -31,17 +31,18 @@ See EdgeInsetsPropType.js for more information.

true.

iosshowsPointsOfInterest bool #

If false points of interest won't be displayed on the map. Default value is true.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); +var { PropTypes } = React; var { Image, MapView, - PropTypes, StyleSheet, Text, TextInput, TouchableOpacity, View, -} = React; +} = ReactNative; var regionText = { latitude: '0', @@ -436,6 +437,6 @@ exports.examples \ No newline at end of file diff --git a/docs/modal.html b/docs/modal.html index e333417283c..7ccb4ef2073 100644 --- a/docs/modal.html +++ b/docs/modal.html @@ -1,4 +1,4 @@ -Modal – React Native | A framework for building native apps using React

Modal #

Edit on GitHub

A Modal component covers the native view (e.g. UIViewController, Activity) +Modal – React Native | A framework for building native apps using React

Modal #

Edit on GitHub

A Modal component covers the native view (e.g. UIViewController, Activity) that contains the React Native root.

Use Modal in hybrid apps that embed React Native; Modal allows the portion of your app written in React Native to present content above the enclosing native view hierarchy.

In apps written with React Native from the root view down, you should use @@ -6,7 +6,8 @@ Navigator instead of Modal. With a top-level Navigator, you have more control over how to present the modal scene over the rest of your app by using the configureScene property.

Props #

animated bool #

onRequestClose Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func #

onShow function #

transparent bool #

visible bool #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Modal, StyleSheet, @@ -14,7 +15,7 @@ configureScene property.

Props < Text, TouchableHighlight, View, -} = React; +} = ReactNative; exports.displayName = (undefined: ?string); exports.framework = 'React'; @@ -180,6 +181,6 @@ exports.examples \ No newline at end of file diff --git a/docs/native-components-android.html b/docs/native-components-android.html index 99fd58689c1..80019b3bbba 100644 --- a/docs/native-components-android.html +++ b/docs/native-components-android.html @@ -1,4 +1,4 @@ -Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still more might be in use in your very own portfolio. React Native has several of the most critical platform components already wrapped, like ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.

Like the native module guide, this too is a more advanced guide that assumes you are somewhat familiar with Android SDK programming. This guide will show you how to build a native UI component, walking you through the implementation of a subset of the existing ImageViewcomponent available in the core React Native library.

ImageView example #

For this example we are going to walk through the implementation requirements to allow the use of ImageViews in JavaScript.

Native views are created and manipulated by extending ViewManager or more commonly SimpleViewManager . A SimpleViewManager is convenient in this case because it applies common properties such as background color, opacity, and Flexbox layout.

These subclasses are essentially singletons - only one instance of each is created by the bridge. They vend native views to the NativeViewHierarchyManager, which delegates back to them to set and update the properties of the views as necessary. The ViewManagers are also typically the delegates for the views, sending events back to JavaScript via the bridge.

Vending a view is simple:

  1. Create the ViewManager subclass.
  2. Implement the createViewInstance method
  3. Expose view property setters using @ReactProp (or @ReactPropGroup) annotation
  4. Register the manager in createViewManagers of the applications package.
  5. Implement the JavaScript module

1. Create the ViewManager subclass #

In this example we create view manager class ReactImageManager that extends SimpleViewManager of type ReactImageView. ReactImageView is the type of object managed by the manager, this will be the custom native view. Name returned by getName is used to reference the native view type from JavaScript.

... +Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still more might be in use in your very own portfolio. React Native has several of the most critical platform components already wrapped, like ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.

Like the native module guide, this too is a more advanced guide that assumes you are somewhat familiar with Android SDK programming. This guide will show you how to build a native UI component, walking you through the implementation of a subset of the existing ImageViewcomponent available in the core React Native library.

ImageView example #

For this example we are going to walk through the implementation requirements to allow the use of ImageViews in JavaScript.

Native views are created and manipulated by extending ViewManager or more commonly SimpleViewManager . A SimpleViewManager is convenient in this case because it applies common properties such as background color, opacity, and Flexbox layout.

These subclasses are essentially singletons - only one instance of each is created by the bridge. They vend native views to the NativeViewHierarchyManager, which delegates back to them to set and update the properties of the views as necessary. The ViewManagers are also typically the delegates for the views, sending events back to JavaScript via the bridge.

Vending a view is simple:

  1. Create the ViewManager subclass.
  2. Implement the createViewInstance method
  3. Expose view property setters using @ReactProp (or @ReactPropGroup) annotation
  4. Register the manager in createViewManagers of the applications package.
  5. Implement the JavaScript module

1. Create the ViewManager subclass #

In this example we create view manager class ReactImageManager that extends SimpleViewManager of type ReactImageView. ReactImageView is the type of object managed by the manager, this will be the custom native view. Name returned by getName is used to reference the native view type from JavaScript.

... public class ReactImageManager extends SimpleViewManager<ReactImageView> { @@ -95,6 +95,6 @@ MyCustomView.propTypes \ No newline at end of file diff --git a/docs/native-components-ios.html b/docs/native-components-ios.html index 4f6a15c8646..32d4eefcb96 100644 --- a/docs/native-components-ios.html +++ b/docs/native-components-ios.html @@ -1,4 +1,4 @@ -Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still more might be in use in your very own portfolio. React Native has several of the most critical platform components already wrapped, like ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.

Like the native module guide, this too is a more advanced guide that assumes you are somewhat familiar with iOS programming. This guide will show you how to build a native UI component, walking you through the implementation of a subset of the existing MapView component available in the core React Native library.

iOS MapView example #

Let's say we want to add an interactive Map to our app - might as well use MKMapView, we just need to make it usable from JavaScript.

Native views are created and manipulated by subclasses of RCTViewManager. These subclasses are similar in function to view controllers, but are essentially singletons - only one instance of each is created by the bridge. They vend native views to the RCTUIManager, which delegates back to them to set and update the properties of the views as necessary. The RCTViewManagers are also typically the delegates for the views, sending events back to JavaScript via the bridge.

Vending a view is simple:

  • Create the basic subclass.
  • Add the RCT_EXPORT_MODULE() marker macro.
  • Implement the -(UIView *)view method.
// RCTMapManager.m +Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still more might be in use in your very own portfolio. React Native has several of the most critical platform components already wrapped, like ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.

Like the native module guide, this too is a more advanced guide that assumes you are somewhat familiar with iOS programming. This guide will show you how to build a native UI component, walking you through the implementation of a subset of the existing MapView component available in the core React Native library.

iOS MapView example #

Let's say we want to add an interactive Map to our app - might as well use MKMapView, we just need to make it usable from JavaScript.

Native views are created and manipulated by subclasses of RCTViewManager. These subclasses are similar in function to view controllers, but are essentially singletons - only one instance of each is created by the bridge. They vend native views to the RCTUIManager, which delegates back to them to set and update the properties of the views as necessary. The RCTViewManagers are also typically the delegates for the views, sending events back to JavaScript via the bridge.

Vending a view is simple:

  • Create the basic subclass.
  • Add the RCT_EXPORT_MODULE() marker macro.
  • Implement the -(UIView *)view method.
// RCTMapManager.m #import <MapKit/MapKit.h> #import "RCTViewManager.h" @@ -243,6 +243,6 @@ import { UIManager \ No newline at end of file diff --git a/docs/native-modules-android.html b/docs/native-modules-android.html index 4fce0589e97..2e725099bc5 100644 --- a/docs/native-modules-android.html +++ b/docs/native-modules-android.html @@ -1,4 +1,4 @@ -Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

Sometimes an app needs access to a platform API that React Native doesn't have a corresponding module for yet. Maybe you want to reuse some existing Java code without having to reimplement it in JavaScript, or write some high performance, multi-threaded code such as for image processing, a database, or any number of advanced extensions.

We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself.

The Toast Module #

This guide will use the Toast example. Let's say we would like to be able to create a toast message from JavaScript.

We start by creating a native module. A native module is a Java class that usually extends the ReactContextBaseJavaModule class and implements the functionality required by the JavaScript. Our goal here is to be able to write ToastAndroid.show('Awesome', ToastAndroid.SHORT); from JavaScript to display a short toast on the screen.

package com.facebook.react.modules.toast; +Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

Sometimes an app needs access to a platform API that React Native doesn't have a corresponding module for yet. Maybe you want to reuse some existing Java code without having to reimplement it in JavaScript, or write some high performance, multi-threaded code such as for image processing, a database, or any number of advanced extensions.

We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself.

The Toast Module #

This guide will use the Toast example. Let's say we would like to be able to create a toast message from JavaScript.

We start by creating a native module. A native module is a Java class that usually extends the ReactContextBaseJavaModule class and implements the functionality required by the JavaScript. Our goal here is to be able to write ToastAndroid.show('Awesome', ToastAndroid.SHORT); from JavaScript to display a short toast on the screen.

package com.facebook.react.modules.toast; import android.widget.Toast; @@ -279,6 +279,6 @@ public void onHostDestroy \ No newline at end of file diff --git a/docs/native-modules-ios.html b/docs/native-modules-ios.html index 42b4827f2e0..e7cb1fb517b 100644 --- a/docs/native-modules-ios.html +++ b/docs/native-modules-ios.html @@ -1,4 +1,4 @@ -Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

Sometimes an app needs access to platform API, and React Native doesn't have a corresponding module yet. Maybe you want to reuse some existing Objective-C, Swift or C++ code without having to reimplement it in JavaScript, or write some high performance, multi-threaded code such as for image processing, a database, or any number of advanced extensions.

We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself.

This is a more advanced guide that shows how to build a native module. It assumes the reader knows Objective-C or Swift and core libraries (Foundation, UIKit).

iOS Calendar Module Example #

This guide will use the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript.

A native module is just an Objective-C class that implements the RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.

// CalendarManager.h +Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

Sometimes an app needs access to platform API, and React Native doesn't have a corresponding module yet. Maybe you want to reuse some existing Objective-C, Swift or C++ code without having to reimplement it in JavaScript, or write some high performance, multi-threaded code such as for image processing, a database, or any number of advanced extensions.

We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself.

This is a more advanced guide that shows how to build a native module. It assumes the reader knows Objective-C or Swift and core libraries (Foundation, UIKit).

iOS Calendar Module Example #

This guide will use the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript.

A native module is just an Objective-C class that implements the RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.

// CalendarManager.h #import "RCTBridgeModule.h" @interface CalendarManager : NSObject <RCTBridgeModule> @@ -152,6 +152,6 @@ class CalendarManager \ No newline at end of file diff --git a/docs/nativemethodsmixin.html b/docs/nativemethodsmixin.html index 75364561ef6..7d177f02455 100644 --- a/docs/nativemethodsmixin.html +++ b/docs/nativemethodsmixin.html @@ -1,27 +1,24 @@ -NativeMethodsMixin – React Native | A framework for building native apps using React

NativeMethodsMixin #

Edit on GitHub

NativeMethodsMixin provides methods to access the underlying native +NativeMethodsMixin – React Native | A framework for building native apps using React

NativeMethodsMixin #

Edit on GitHub

NativeMethodsMixin provides methods to access the underlying native component directly. This can be useful in cases when you want to focus a view or measure its on-screen dimensions, for example.

The methods described here are available on most of the default components provided by React Native. Note, however, that they are not available on composite components that aren't directly backed by a native view. This will generally include most components that you define in your own app. For more information, see Direct -Manipulation.

Methods #

static measure(callback: MeasureOnSuccessCallback) #

Determines the location on screen, width, and height of the given view and +Manipulation.

Methods #

static measure(callback) #

Determines the location on screen, width, and height of the given view and returns the values via an async callback. If successful, the callback will be called with the following arguments:

  • x
  • y
  • width
  • height
  • pageX
  • pageY

Note that these measurements are not available until after the rendering has been completed in native. If you need the measurements as soon as possible, consider using the onLayout -prop instead.

static measureInWindow(callback: MeasureInWindowOnSuccessCallback) #

Determines the location of the given view in the window and returns the +prop instead.

static measureInWindow(callback) #

Determines the location of the given view in the window and returns the values via an async callback. If the React root view is embedded in another native view, this will give you the absolute coordinates. If successful, the callback will be called with the following arguments:

  • x
  • y
  • width
  • height

Note that these measurements are not available until after the rendering -has been completed in native.

static measureLayout(relativeToNativeNode: number, onSuccess: MeasureLayoutOnSuccessCallback, onFail: () => void) #

Like measure(), but measures the view relative an ancestor, +has been completed in native.

static measureLayout(relativeToNativeNode, onSuccess, onFail) #

Like measure(), but measures the view relative an ancestor, specified as relativeToNativeNode. This means that the returned x, y are relative to the origin x, y of the ancestor view.

As always, to obtain a native node handle for a component, you can use -React.findNodeHandle(component).

static setNativeProps(nativeProps: Object) #

This function sends props straight to native. They will not participate in -future diff process - this means that if you do not include them in the -next render, they will remain active (see Direct -Manipulation).

static focus() #

Requests focus for the given input or view. The exact behavior triggered +React.findNodeHandle(component).

static focus() #

Requests focus for the given input or view. The exact behavior triggered will depend on the platform and type of view.

static blur() #

Removes focus from an input or view. This is the opposite of focus().

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/navigator-comparison.html b/docs/navigator-comparison.html index e98b16ab2d2..fb9f1df0ba3 100644 --- a/docs/navigator-comparison.html +++ b/docs/navigator-comparison.html @@ -1,4 +1,4 @@ -Navigator Comparison – React Native | A framework for building native apps using React

Navigator Comparison #

Edit on GitHub

The differences between Navigator +Navigator Comparison – React Native | A framework for building native apps using React

Navigator Comparison #

Edit on GitHub

The differences between Navigator and NavigatorIOS are a common source of confusion for newcomers.

Both Navigator and NavigatorIOS are components that allow you to manage the navigation in your app between various "scenes" (another word @@ -12,7 +12,7 @@ class, and Navigator re-implements that functionality entirely in JavaScript as a React component. A corollary of this is that Navigator will be compatible with Android and iOS, whereas NavigatorIOS will only work on the one platform. Below is an itemized list of differences -between the two.

Navigator #

  • Extensive API makes it completely customizable from JavaScript.
  • Under active development from the React Native team.
  • Written in JavaScript.
  • Works on iOS and Android.
  • Includes a simple navigation bar component similar to the default NavigatorIOS bar: Navigator.NavigationBar, and another with breadcrumbs called Navigator.BreadcrumbNavigationBar. See the UIExplorer demo to try them out and see how to use them.
    • Currently animations are good and improving, but they are still less refined than Apple's, which you get from NavigatorIOS.
  • You can provide your own navigation bar by passing it through the navigationBar prop.

NavigatorIOS #

  • Small, limited API makes it much less customizable than Navigator in its current form.
  • Development belongs to open-source community - not used by the React Native team on their apps.
    • A result of this is that there is currently a backlog of unresolved bugs, nobody who uses this has stepped up to take ownership for it yet.
  • Wraps UIKit, so it works exactly the same as it would on another native app. Lives in Objective-C and JavaScript.
    • Consequently, you get the animations and behavior that Apple has developed.
  • iOS only.
  • Includes a navigation bar by default; this navigation bar is not a React Native view component and the style can only be slightly modified.

For most non-trivial apps, you will want to use Navigator - it won't be long before you run into issues when trying to do anything complex with NavigatorIOS.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/navigator.html b/docs/navigator.html index 3d8ea2587f9..378ca91f9f9 100644 --- a/docs/navigator.html +++ b/docs/navigator.html @@ -1,4 +1,4 @@ -Navigator – React Native | A framework for building native apps using React

Navigator #

Edit on GitHub

Use Navigator to transition between different scenes in your app. To +Navigator – React Native | A framework for building native apps using React

Navigator #

Edit on GitHub

Use Navigator to transition between different scenes in your app. To accomplish this, provide route objects to the navigator to identify each scene, and also a renderScene function that the navigator can use to render the scene for a given route.

To change the animation or gesture properties of the scene, provide a @@ -23,12 +23,7 @@ scene config options.

Basic Usag }} /> } - />

Navigator Methods #

If you have a ref to the Navigator element, you can invoke several methods -on it to trigger navigation:

  • getCurrentRoutes() - returns the current list of routes
  • jumpBack() - Jump backward without unmounting the current scene
  • jumpForward() - Jump forward to the next scene in the route stack
  • jumpTo(route) - Transition to an existing scene without unmounting
  • push(route) - Navigate forward to a new scene, squashing any scenes - that you could jumpForward to
  • pop() - Transition back and unmount the current scene
  • replace(route) - Replace the current scene with a new route
  • replaceAtIndex(route, index) - Replace a scene as specified by an index
  • replacePrevious(route) - Replace the previous scene
  • resetTo(route) - Navigate to a new scene and reset route stack
  • immediatelyResetRouteStack(routeStack) - Reset every scene with an - array of routes
  • popToRoute(route) - Pop to a particular scene, as specified by its - route. All scenes after it will be unmounted
  • popToTop() - Pop to the first scene in the stack, unmounting every - other scene

Props #

configureScene function #

Optional function that allows configuration about scene animations and + />

Props #

configureScene function #

Optional function that allows configuration about scene animations and gestures. Will be invoked with the route and the routeStack and should return a scene configuration object

(route, routeStack) => Navigator.SceneConfigs.FloatFromRight

Available options are:

  • Navigator.SceneConfigs.PushFromRight (default)
  • Navigator.SceneConfigs.FloatFromRight
  • Navigator.SceneConfigs.FloatFromLeft
  • Navigator.SceneConfigs.FloatFromBottom
  • Navigator.SceneConfigs.FloatFromBottomAndroid
  • Navigator.SceneConfigs.FadeAndroid
  • Navigator.SceneConfigs.HorizontalSwipeJump
  • Navigator.SceneConfigs.HorizontalSwipeJumpFromRight
  • Navigator.SceneConfigs.VerticalUpSwipeJump
  • Navigator.SceneConfigs.VerticalDownSwipeJump

initialRoute object #

Specify a route to start on. A route is an object that the navigator will use to identify each scene to render. initialRoute must be @@ -40,7 +35,10 @@ transitions. The component will receive two props: navigator and

navigator object #

Optionally provide the navigator object from a parent Navigator

onDidFocus function #

Will be called with the new route of each scene after the transition is complete or after the initial mounting

onWillFocus function #

Will emit the target route upon mounting and before each nav transition

renderScene function #

Required function which renders the scene for a given route. Will be invoked with the route and the navigator object

(route, navigator) => - <MySceneComponent title={route.title} navigator={navigator} />

sceneStyle View#style #

Styles to apply to the container of each scene

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/navigatorios.html b/docs/navigatorios.html index 9ea857b4457..63ea7b8d443 100644 --- a/docs/navigatorios.html +++ b/docs/navigatorios.html @@ -1,4 +1,4 @@ -NavigatorIOS – React Native | A framework for building native apps using React

NavigatorIOS #

Edit on GitHub

NavigatorIOS wraps UIKit navigation and allows you to add back-swipe +NavigatorIOS – React Native | A framework for building native apps using React

NavigatorIOS #

Edit on GitHub

NavigatorIOS wraps UIKit navigation and allows you to add back-swipe functionality across your app.

NOTE: This Component is not maintained by Facebook

This component is under community responsibility. If a pure JavaScript solution fits your needs you may try the Navigator component instead.

Routes #

A route is an object used to describe each page in the navigator. The first @@ -23,9 +23,7 @@ is passed as a prop to any component rendered by NavigatorIOS.

this.props.navigator.push(nextRoute); }, ... -});

A navigation object contains the following functions:

  • push(route) - Navigate forward to a new route
  • pop() - Go back one page
  • popN(n) - Go back N pages at once. When N=1, behavior matches pop()
  • replace(route) - Replace the route for the current page and immediately -load the view for the new route
  • replacePrevious(route) - Replace the route/view for the previous page
  • replacePreviousAndPop(route) - Replaces the previous route/view and -transitions back to it
  • resetTo(route) - Replaces the top item and popToTop
  • popToRoute(route) - Go back to the item for a particular route object
  • popToTop() - Go back to the top item

Navigator functions are also available on the NavigatorIOS component:

var MyView = React.createClass({ +});

Navigator functions are also available on the NavigatorIOS component:

var MyView = React.createClass({ _handleNavigationRequest: function() { this.refs.nav.push(otherRoute); }, @@ -41,9 +39,103 @@ the configuration for that route's navigation bar, overriding any props passed to the NavigatorIOS component.

Props #

barTintColor string #

The default background color of the navigation bar

initialRoute {component: function, title: string, passProps: object, backButtonIcon: Image.propTypes.source, backButtonTitle: string, leftButtonIcon: Image.propTypes.source, leftButtonTitle: string, onLeftButtonPress: function, rightButtonIcon: Image.propTypes.source, rightButtonTitle: string, onRightButtonPress: function, wrapperStyle: [object Object], navigationBarHidden: bool, shadowHidden: bool, tintColor: string, barTintColor: string, titleTextColor: string, translucent: bool} #

NavigatorIOS uses "route" objects to identify child views, their props, and navigation bar configuration. "push" and all the other navigation operations expect routes to be like this:

itemWrapperStyle View#style #

The default wrapper style for components in the navigator. -A common use case is to set the backgroundColor for every page

navigationBarHidden bool #

A Boolean value that indicates whether the navigation bar is hidden by default

shadowHidden bool #

A Boolean value that indicates whether to hide the 1px hairline shadow by default

tintColor string #

The default color used for buttons in the navigation bar

titleTextColor string #

The default text color of the navigation bar title

translucent bool #

A Boolean value that indicates whether the navigation bar is translucent by default

Examples #

Edit on GitHub
'use strict'; +A common use case is to set the backgroundColor for every page

navigationBarHidden bool #

A Boolean value that indicates whether the navigation bar is hidden by default

shadowHidden bool #

A Boolean value that indicates whether to hide the 1px hairline shadow by default

tintColor string #

The default color used for buttons in the navigation bar

titleTextColor string #

The default text color of the navigation bar title

translucent bool #

A Boolean value that indicates whether the navigation bar is translucent by default

Methods #

push(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Navigate forward to a new route

popN(n: number) #

Go back N pages at once. When N=1, behavior matches pop()

pop() #

Go back one page

replaceAtIndex(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}, index: number) #

Replace a route in the navigation stack.

index specifies the route in the stack that should be replaced. +If it's negative, it counts from the back.

replace(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Replace the route for the current page and immediately +load the view for the new route.

replacePrevious(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Replace the route/view for the previous page.

popToTop() #

Go back to the top item

popToRoute(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Go back to the item for a particular route object

replacePreviousAndPop(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Replaces the previous route/view and transitions back to it.

resetTo(route: { + component: Function; + title: string; + passProps?: Object; + backButtonTitle?: string; + backButtonIcon?: Object; + leftButtonTitle?: string; + leftButtonIcon?: Object; + onLeftButtonPress?: Function; + rightButtonTitle?: string; + rightButtonIcon?: Object; + onRightButtonPress?: Function; + wrapperStyle?: any; +}) #

Replaces the top item and popToTop

Examples #

Edit on GitHub
'use strict'; -const React = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); const ViewExample = require('./ViewExample'); const createExamplePage = require('./createExamplePage'); const { @@ -54,7 +146,7 @@ const { Text, TouchableHighlight, View, -} = React; +} = ReactNative; const EmptyPage = React.createClass({ render: function() { @@ -301,6 +393,6 @@ module.exports \ No newline at end of file diff --git a/docs/netinfo.html b/docs/netinfo.html index d9f019fc4e3..57fd7ea67b6 100644 --- a/docs/netinfo.html +++ b/docs/netinfo.html @@ -1,4 +1,4 @@ -NetInfo – React Native | A framework for building native apps using React

NetInfo #

Edit on GitHub

NetInfo exposes info about online/offline status

NetInfo.fetch().done((reach) => { +NetInfo – React Native | A framework for building native apps using React

NetInfo #

Edit on GitHub

NetInfo exposes info about online/offline status

NetInfo.fetch().done((reach) => { console.log('Initial: ' + reach); }); function handleFirstConnectivityChange(reach) { @@ -35,15 +35,16 @@ internet connectivity.

NetInfo.isConnected.addEventListener( 'change', handleFirstConnectivityChange -);

Methods #

static addEventListener(eventName: ChangeEventName, handler: Function) #

static removeEventListener(eventName: ChangeEventName, handler: Function) #

static fetch() #

static isConnectionExpensive() #

Properties #

isConnected: ObjectExpression #

Examples #

Edit on GitHub
'use strict'; +);

Methods #

static addEventListener(eventName, handler) #

static removeEventListener(eventName, handler) #

static fetch() #

static isConnectionExpensive() #

Properties #

isConnected: ObjectExpression #

Examples #

Edit on GitHub
'use strict'; -const React = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); const { NetInfo, Text, View, TouchableWithoutFeedback, -} = React; +} = ReactNative; const ConnectionInfoSubscription = React.createClass({ getInitialState() { @@ -217,6 +218,6 @@ exports.examples \ No newline at end of file diff --git a/docs/network.html b/docs/network.html index e8b12f82fd3..aea5392279f 100644 --- a/docs/network.html +++ b/docs/network.html @@ -1,4 +1,4 @@ -Network – React Native | A framework for building native apps using React

Network #

Edit on GitHub

One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example.

Fetch #

fetch is a better networking API being worked on by the standards committee and is already available in Chrome. It is available in React Native by default.

Usage #

fetch('https://mywebsite.com/endpoint/')

Include a request object as the optional second argument to customize the HTTP request:

fetch('https://mywebsite.com/endpoint/', { +Network – React Native | A framework for building native apps using React

Network #

Edit on GitHub

One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example.

Fetch #

fetch is a better networking API being worked on by the standards committee and is already available in Chrome. It is available in React Native by default.

Usage #

fetch('https://mywebsite.com/endpoint/')

Include a request object as the optional second argument to customize the HTTP request:

fetch('https://mywebsite.com/endpoint/', { method: 'POST', headers: { 'Accept': 'application/json', @@ -61,6 +61,27 @@ request.onreadystatechange } }; +request.open('GET', 'https://mywebsite.com/endpoint.php'); +request.send();

You can also use -

var request = new XMLHttpRequest(); + +function onLoad() { + console.log(request.status); + console.log(request.responseText); +}; + +function onTimeout() { + console.log('Timeout'); + console.log(request.responseText); +}; + +function onError() { + console.log('General network error'); + console.log(request.responseText); +}; + +request.onload = onLoad; +request.ontimeout = onTimeout; +request.onerror = onError; request.open('GET', 'https://mywebsite.com/endpoint.php'); request.send();

Please follow the MDN Documentation for a complete description of the API.

As a developer, you're probably not going to use XMLHttpRequest directly as its API is very tedious to work with. But the fact that it is implemented and compatible with the browser API gives you the ability to use third-party libraries such as frisbee or axios directly from npm.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/panresponder.html b/docs/panresponder.html index 8a481987cdd..eb1e9492ebd 100644 --- a/docs/panresponder.html +++ b/docs/panresponder.html @@ -1,4 +1,4 @@ -PanResponder – React Native | A framework for building native apps using React

PanResponder #

Edit on GitHub

PanResponder reconciles several touches into a single gesture. It makes +PanResponder – React Native | A framework for building native apps using React

PanResponder #

Edit on GitHub

PanResponder reconciles several touches into a single gesture. It makes single-touch gestures resilient to extra touches, and can be used to recognize simple multi-touch gestures.

It provides a predictable wrapper of the responder handlers provided by the gesture responder system. @@ -46,7 +46,7 @@ native event object:

onPanResponderMov <View {...this._panResponder.panHandlers} /> ); },

Working Example #

To see it in action, try the -PanResponder example in UIExplorer

Methods #

static create(config: object) #

@param {object} config Enhanced versions of all of the responder callbacks +PanResponder example in UIExplorer

Methods #

static create(config) #

@param {object} config Enhanced versions of all of the responder callbacks that provide not only the typical ResponderSyntheticEvent, but also the PanResponder gesture state. Simply replace the word Responder with PanResponder in each of the typical onResponder* callbacks. For @@ -59,17 +59,16 @@ being processed by the gesture and gestureState being updated accordingly. (numberActiveTouches) may not be totally accurate unless you are the responder.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { PanResponder, StyleSheet, View, processColor, -} = React; +} = ReactNative; var CIRCLE_SIZE = 80; -var CIRCLE_COLOR = 'blue'; -var CIRCLE_HIGHLIGHT_COLOR = 'green'; var PanResponderExample = React.createClass({ @@ -98,13 +97,14 @@ are the responder.

this._circleStyles ={ style:{ left:this._previousLeft, - top:this._previousTop + top:this._previousTop, + backgroundColor:'green',}};}, componentDidMount:function(){ - this._updatePosition(); + this._updateNativeStyles();}, render:function(){ @@ -123,24 +123,16 @@ are the responder.

}, _highlight:function(){ - const circle =this.circle; - circle && circle.setNativeProps({ - style:{ - backgroundColor:processColor(CIRCLE_HIGHLIGHT_COLOR) - } - }); + this._circleStyles.style.backgroundColor ='blue'; + this._updateNativeStyles();}, _unHighlight:function(){ - const circle =this.circle; - circle && circle.setNativeProps({ - style:{ - backgroundColor:processColor(CIRCLE_COLOR) - } - }); + this._circleStyles.style.backgroundColor ='green'; + this._updateNativeStyles();}, - _updatePosition:function(){ + _updateNativeStyles:function(){this.circle && this.circle.setNativeProps(this._circleStyles);}, @@ -160,7 +152,7 @@ are the responder.

:function(e: Object, gestureState: Object){this._circleStyles.style.left =this._previousLeft + gestureState.dx;this._circleStyles.style.top =this._previousTop + gestureState.dy; - this._updatePosition(); + this._updateNativeStyles();}, _handlePanResponderEnd:function(e: Object, gestureState: Object){this._unHighlight(); @@ -174,7 +166,6 @@ are the responder.

: CIRCLE_SIZE, height: CIRCLE_SIZE, borderRadius: CIRCLE_SIZE /2, - backgroundColor: CIRCLE_COLOR, position:'absolute', left:0, top:0, @@ -201,6 +192,6 @@ module.exports \ No newline at end of file diff --git a/docs/performance.html b/docs/performance.html index 13bb6ae9059..cba218732ad 100644 --- a/docs/performance.html +++ b/docs/performance.html @@ -1,4 +1,4 @@ -Performance – React Native | A framework for building native apps using React

Performance #

Edit on GitHub

A compelling reason for using React Native instead of WebView-based +Performance – React Native | A framework for building native apps using React

Performance #

Edit on GitHub

A compelling reason for using React Native instead of WebView-based tools is to achieve 60 FPS and a native look & feel to your apps. Where possible, we would like for React Native to do the right thing and help you to focus on your app instead of performance optimization, but there @@ -200,6 +200,6 @@ learn to use systrace.

\ No newline at end of file diff --git a/docs/picker.html b/docs/picker.html index 5e2266f1953..3dfad906e9a 100644 --- a/docs/picker.html +++ b/docs/picker.html @@ -1,4 +1,4 @@ -Picker – React Native | A framework for building native apps using React

Picker #

Edit on GitHub

Renders the native picker component on iOS and Android. Example:

<Picker +Picker – React Native | A framework for building native apps using React

Picker #

Edit on GitHub

Renders the native picker component on iOS and Android. Example:

<Picker selectedValue={this.state.language} onValueChange={(lang) => this.setState({language: lang})}> <Picker.Item label="Java" value="java" /> @@ -22,6 +22,6 @@ selection.

\ No newline at end of file diff --git a/docs/pickerios.html b/docs/pickerios.html index c12d3c6cb12..2434ff8ab2a 100644 --- a/docs/pickerios.html +++ b/docs/pickerios.html @@ -1,11 +1,12 @@ -PickerIOS – React Native | A framework for building native apps using React

PickerIOS #

Edit on GitHub

Props #

itemStyle itemStylePropType #

onValueChange function #

selectedValue any #

Examples #

Edit on GitHub
'use strict'; +PickerIOS – React Native | A framework for building native apps using React

PickerIOS #

Edit on GitHub

Props #

itemStyle itemStylePropType #

onValueChange function #

selectedValue any #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { PickerIOS, Text, View, -} = React; +} = ReactNative; var PickerItemIOS = PickerIOS.Item; @@ -153,6 +154,6 @@ exports.examples \ No newline at end of file diff --git a/docs/pixelratio.html b/docs/pixelratio.html index 5a9a3045844..e79f1898c02 100644 --- a/docs/pixelratio.html +++ b/docs/pixelratio.html @@ -1,4 +1,4 @@ -PixelRatio – React Native | A framework for building native apps using React

PixelRatio #

Edit on GitHub

PixelRatio class gives access to the device pixel density.

Fetching a correctly sized image #

You should get a higher resolution image if you are on a high pixel density +PixelRatio – React Native | A framework for building native apps using React

PixelRatio #

Edit on GitHub

PixelRatio class gives access to the device pixel density.

Fetching a correctly sized image #

You should get a higher resolution image if you are on a high pixel density device. A good rule of thumb is to multiply the size of the image you display by the pixel ratio.

var image = getImage({ width: PixelRatio.getPixelSizeForLayoutSize(200), @@ -8,7 +8,7 @@ by the pixel ratio.

static getPixelSizeForLayoutSize(layoutSize: number) #

Converts a layout size (dp) to pixel size (px).

Guaranteed to return an integer number.

static roundToNearestPixel(layoutSize: number) #

Rounds a layout size (dp) to the nearest layout size that corresponds to +@platform android

static getPixelSizeForLayoutSize(layoutSize) #

Converts a layout size (dp) to pixel size (px).

Guaranteed to return an integer number.

static roundToNearestPixel(layoutSize) #

Rounds a layout size (dp) to the nearest layout size that corresponds to an integer number of pixels. For example, on a device with a PixelRatio of 3, PixelRatio.roundToNearestPixel(8.4) = 8.33, which corresponds to exactly (8.33 * 3) = 25 pixels.

static startDetecting() #

// No-op for iOS, but used on the web. Should not be documented.

Description #

Edit on GitHub

Pixel Grid Snapping #

In iOS, you can specify positions and dimensions for elements with arbitrary precision, for example 29.674825. But, ultimately the physical display only have a fixed number of pixels, for example 640×960 for iphone 4 or 750×1334 for iphone 6. iOS tries to be as faithful as possible to the user value by spreading one original pixel into multiple ones to trick the eye. The downside of this technique is that it makes the resulting element look blurry.

In practice, we found out that developers do not want this feature and they have to work around it by doing manual rounding in order to avoid having blurry elements. In React Native, we are rounding all the pixels automatically.

We have to be careful when to do this rounding. You never want to work with rounded and unrounded values at the same time as you're going to accumulate rounding errors. Having even one rounding error is deadly because a one pixel border may vanish or be twice as big.

In React Native, everything in JS and within the layout engine work with arbitrary precision numbers. It's only when we set the position and dimensions of the native element on the main thread that we round. Also, rounding is done relative to the root rather than the parent, again to avoid accumulating rounding errors.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/platform-specific-code.html b/docs/platform-specific-code.html index 0b365d1f0a2..b2b2a62f26f 100644 --- a/docs/platform-specific-code.html +++ b/docs/platform-specific-code.html @@ -1,4 +1,4 @@ -Platform Specific Code – React Native | A framework for building native apps using React

Platform Specific Code #

Edit on GitHub

When building a cross-platform app, the need to write different code for different platforms may arise. This can always be achieved by organizing the various components in different folders:

/common/components/ +Platform Specific Code – React Native | A framework for building native apps using React

Platform Specific Code #

Edit on GitHub

When building a cross-platform app, the need to write different code for different platforms may arise. This can always be achieved by organizing the various components in different folders:

/common/components/ /android/components/ /ios/components/

Another option may be naming the components differently depending on the platform they are going to be used in:

BigButtonIOS.js BigButtonAndroid.js

But React Native provides two alternatives to easily organize your code separating it by platform:

Platform specific extensions #

React Native will detect when a file has a .ios. or .android. extension and load the right file for each platform when requiring them from other components.

For example, you can have these files in your project:

BigButton.ios.js @@ -26,6 +26,6 @@ BigButton.android \ No newline at end of file diff --git a/docs/progressbarandroid.html b/docs/progressbarandroid.html index 2ce55e842db..2384d7a4532 100644 --- a/docs/progressbarandroid.html +++ b/docs/progressbarandroid.html @@ -1,4 +1,4 @@ -ProgressBarAndroid – React Native | A framework for building native apps using React

ProgressBarAndroid #

Edit on GitHub

React component that wraps the Android-only ProgressBar. This component is used to indicate +ProgressBarAndroid – React Native | A framework for building native apps using React

ProgressBarAndroid #

Edit on GitHub

React component that wraps the Android-only ProgressBar. This component is used to indicate that the app is loading or there is some activity in the app.

Example:

render: function() { var progressBar = <View style={styles.container}> @@ -124,6 +124,6 @@ module.exports \ No newline at end of file diff --git a/docs/progressviewios.html b/docs/progressviewios.html index e248cf36f5f..8dbd20c38c4 100644 --- a/docs/progressviewios.html +++ b/docs/progressviewios.html @@ -1,11 +1,12 @@ -ProgressViewIOS – React Native | A framework for building native apps using React

ProgressViewIOS #

Edit on GitHub

Use ProgressViewIOS to render a UIProgressView on iOS.

Props #

progress number #

The progress value (between 0 and 1).

progressImage Image.propTypes.source #

A stretchable image to display as the progress bar.

progressTintColor string #

The tint color of the progress bar itself.

progressViewStyle enum('default', 'bar') #

The progress bar style.

trackImage Image.propTypes.source #

A stretchable image to display behind the progress bar.

trackTintColor string #

The tint color of the progress bar track.

Examples #

Edit on GitHub
'use strict'; +ProgressViewIOS – React Native | A framework for building native apps using React

ProgressViewIOS #

Edit on GitHub

Use ProgressViewIOS to render a UIProgressView on iOS.

Props #

progress number #

The progress value (between 0 and 1).

progressImage Image.propTypes.source #

A stretchable image to display as the progress bar.

progressTintColor string #

The tint color of the progress bar itself.

progressViewStyle enum('default', 'bar') #

The progress bar style.

trackImage Image.propTypes.source #

A stretchable image to display behind the progress bar.

trackTintColor string #

The tint color of the progress bar track.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { ProgressViewIOS, StyleSheet, View, -} = React; +} = ReactNative; var TimerMixin = require('react-timer-mixin'); var ProgressViewExample = React.createClass({ @@ -82,6 +83,6 @@ exports.examples \ No newline at end of file diff --git a/docs/pushnotificationios.html b/docs/pushnotificationios.html index e610987c7ba..ad210bb342b 100644 --- a/docs/pushnotificationios.html +++ b/docs/pushnotificationios.html @@ -1,4 +1,4 @@ -PushNotificationIOS – React Native | A framework for building native apps using React

PushNotificationIOS #

Edit on GitHub

Handle push notifications for your app, including permission handling and +PushNotificationIOS – React Native | A framework for building native apps using React

PushNotificationIOS #

Edit on GitHub

Handle push notifications for your app, including permission handling and icon badge number.

To get up and running, configure your notifications with Apple and your server-side system. To get an idea, this is the Parse guide.

Manually link the PushNotificationIOS library

  • Be sure to add the following to your Header Search Paths: $(SRCROOT)/../node_modules/react-native/Libraries/PushNotificationIOS
  • Set the search to recursive

Finally, to enable support for notification and register events you need to augment your AppDelegate.

At the top of your AppDelegate.m:

#import "RCTPushNotificationManager.h"

And then in your AppDelegate implementation add the following:

Methods #

static presentLocalNotification(details: Object) #

Schedules the localNotification for immediate presentation.

details is an object containing:

  • alertBody : The message displayed in the notification alert.
  • alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
  • soundName : The sound played when the notification is fired (optional).
  • category : The category of this notification, required for actionable notifications (optional).
  • userInfo : An optional object containing additional notification data.

static scheduleLocalNotification(details: Object) #

Schedules the localNotification for future presentation.

details is an object containing:

  • fireDate : The date and time when the system should deliver the notification.
  • alertBody : The message displayed in the notification alert.
  • alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
  • soundName : The sound played when the notification is fired (optional).
  • category : The category of this notification, required for actionable notifications (optional).
  • userInfo : An optional object containing additional notification data.

static cancelAllLocalNotifications() #

Cancels all scheduled localNotifications

static setApplicationIconBadgeNumber(number: number) #

Sets the badge number for the app icon on the home screen

static getApplicationIconBadgeNumber(callback: Function) #

Gets the current badge number for the app icon on the home screen

static cancelLocalNotifications(userInfo: Object) #

Cancel local notifications.

Optionally restricts the set of canceled notifications to those + }

Methods #

static presentLocalNotification(details) #

Schedules the localNotification for immediate presentation.

details is an object containing:

  • alertBody : The message displayed in the notification alert.
  • alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
  • soundName : The sound played when the notification is fired (optional).
  • category : The category of this notification, required for actionable notifications (optional).
  • userInfo : An optional object containing additional notification data.

static scheduleLocalNotification(details) #

Schedules the localNotification for future presentation.

details is an object containing:

  • fireDate : The date and time when the system should deliver the notification.
  • alertBody : The message displayed in the notification alert.
  • alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
  • soundName : The sound played when the notification is fired (optional).
  • category : The category of this notification, required for actionable notifications (optional).
  • userInfo : An optional object containing additional notification data.

static cancelAllLocalNotifications() #

Cancels all scheduled localNotifications

static setApplicationIconBadgeNumber(number) #

Sets the badge number for the app icon on the home screen

static getApplicationIconBadgeNumber(callback) #

Gets the current badge number for the app icon on the home screen

static cancelLocalNotifications(userInfo) #

Cancel local notifications.

Optionally restricts the set of canceled notifications to those notifications whose userInfo fields match the corresponding fields -in the userInfo argument.

static addEventListener(type: string, handler: Function) #

Attaches a listener to remote or local notification events while the app is running +in the userInfo argument.

static addEventListener(type, handler) #

Attaches a listener to remote or local notification events while the app is running in the foreground or the background.

Valid events are:

  • notification : Fired when a remote notification is received. The handler will be invoked with an instance of PushNotificationIOS.
  • localNotification : Fired when a local notification is received. The handler will be invoked with an instance of PushNotificationIOS.
  • register: Fired when the user registers for remote notifications. The -handler will be invoked with a hex string representing the deviceToken.

static requestPermissions(permissions?: { - alert?: boolean, - badge?: boolean, - sound?: boolean - }) #

Requests notification permissions from iOS, prompting the user's +handler will be invoked with a hex string representing the deviceToken.

static requestPermissions(permissions?) #

Requests notification permissions from iOS, prompting the user's dialog box. By default, it will request all notification permissions, but a subset of these can be requested by passing a map of requested permissions. @@ -38,15 +34,16 @@ The following permissions are supported:

  • alert
  • < will be requested.

static abandonPermissions() #

Unregister for all remote notifications received via Apple Push Notification service.

You should call this method in rare circumstances only, such as when a new version of the app removes support for all types of remote notifications. Users can temporarily prevent apps from receiving remote notifications through the Notifications section of -the Settings app. Apps unregistered through this method can always re-register.

static checkPermissions(callback: Function) #

See what push permissions are currently enabled. callback will be -invoked with a permissions object:

  • alert :boolean
  • badge :boolean
  • sound :boolean

static removeEventListener(type: string, handler: Function) #

Removes the event listener. Do this in componentWillUnmount to prevent +the Settings app. Apps unregistered through this method can always re-register.

static checkPermissions(callback) #

See what push permissions are currently enabled. callback will be +invoked with a permissions object:

  • alert :boolean
  • badge :boolean
  • sound :boolean

static removeEventListener(type, handler) #

Removes the event listener. Do this in componentWillUnmount to prevent memory leaks

static popInitialNotification() #

An initial notification will be available if the app was cold-launched from a notification.

The first caller of popInitialNotification will get the initial -notification object, or null. Subsequent invocations will return null.

constructor(nativeNotif: Object) #

You will never need to instantiate PushNotificationIOS yourself. +notification object, or null. Subsequent invocations will return null.

constructor(nativeNotif) #

You will never need to instantiate PushNotificationIOS yourself. Listening to the notification event and invoking popInitialNotification is sufficient

getMessage() #

An alias for getAlert to get the notification's main message string

getSound() #

Gets the sound string from the aps object

getAlert() #

Gets the notification's main message from the aps object

getBadgeCount() #

Gets the badge count number from the aps object

getData() #

Gets the data object on the notif

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { AlertIOS, PushNotificationIOS, @@ -54,7 +51,7 @@ Listening to the notification event and invoking Text, TouchableHighlight, View, -} = React; +} = ReactNative; var Button = React.createClass({ render: function() { @@ -203,6 +200,6 @@ exports.examples \ No newline at end of file diff --git a/docs/refreshcontrol.html b/docs/refreshcontrol.html index 78e7b326971..42ad2e72082 100644 --- a/docs/refreshcontrol.html +++ b/docs/refreshcontrol.html @@ -1,4 +1,4 @@ -RefreshControl – React Native | A framework for building native apps using React

RefreshControl #

Edit on GitHub

This component is used inside a ScrollView or ListView to add pull to refresh +RefreshControl – React Native | A framework for building native apps using React

RefreshControl #

Edit on GitHub

This component is used inside a ScrollView or ListView to add pull to refresh functionality. When the ScrollView is at scrollY: 0, swiping down triggers an onRefresh event.

Usage example #

class RefreshableList extends Component { constructor(props) { @@ -32,9 +32,10 @@ triggers an onRefresh event.

} ... }

Note: refreshing is a controlled prop, this is why it needs to be set to true -in the onRefresh function otherwise the refresh indicator will stop immediatly.

Props #

onRefresh function #

Called when the view starts refreshing.

refreshing bool #

Whether the view should be indicating an active refresh.

androidcolors [color] #

The colors (at least one) that will be used to draw the refresh indicator.

androidenabled bool #

Whether the pull to refresh functionality is enabled.

androidprogressBackgroundColor color #

The background color of the refresh indicator.

androidsize RefreshLayoutConsts.SIZE.DEFAULT #

Size of the refresh indicator, see RefreshControl.SIZE.

iostintColor color #

The color of the refresh indicator.

iostitle string #

The title displayed under the refresh indicator.

Examples #

Edit on GitHub
'use strict'; +in the onRefresh function otherwise the refresh indicator will stop immediatly.

Props #

onRefresh function #

Called when the view starts refreshing.

refreshing bool #

Whether the view should be indicating an active refresh.

androidcolors [color] #

The colors (at least one) that will be used to draw the refresh indicator.

androidenabled bool #

Whether the pull to refresh functionality is enabled.

androidprogressBackgroundColor color #

The background color of the refresh indicator.

androidsize RefreshLayoutConsts.SIZE.DEFAULT #

Size of the refresh indicator, see RefreshControl.SIZE.

iostintColor color #

The color of the refresh indicator.

iostitle string #

The title displayed under the refresh indicator.

iostitleColor color #

Title color.

Examples #

Edit on GitHub
'use strict'; -const React = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); const { ScrollView, StyleSheet, @@ -42,7 +43,7 @@ const { Text, TouchableWithoutFeedback, View, -} = React; +} = ReactNative; const styles = StyleSheet.create({ row: { @@ -113,6 +114,7 @@ const RefreshControlExample = React={this._onRefresh} tintColor="#ff0000" title="Loading..." + titleColor="#00ff00" colors={['#ff0000', '#00ff00', '#0000ff']} progressBackgroundColor="#ffff00" /> @@ -158,6 +160,6 @@ module.exports \ No newline at end of file diff --git a/docs/running-on-device-android.html b/docs/running-on-device-android.html index 38b06475a85..394e56af3e7 100644 --- a/docs/running-on-device-android.html +++ b/docs/running-on-device-android.html @@ -1,4 +1,4 @@ -Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Prerequisite: USB Debugging #

You'll need this in order to install your app on your device. First, make sure you have USB debugging enabled on your device.

Check that your device has been successfully connected by running adb devices:

$ adb devices +Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Prerequisite: USB Debugging #

You'll need this in order to install your app on your device. First, make sure you have USB debugging enabled on your device.

Check that your device has been successfully connected by running adb devices:

$ adb devices List of devices attached emulator-5554 offline # Google emulator 14ed2fcc device # Physical device

Seeing device in the right column means the device is connected. Android - go figure :) You must have only one device connected.

Now you can use react-native run-android to install and launch your app on the 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.

Hint

Most modern android devices don't have a hardware menu button, which we use to trigger the developer menu. In that case you can shake the device to open the dev menu (to reload, debug, etc.). Alternatively, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).

Using adb reverse #

Note that this option is available on devices running android 5.0+ (API 21).

Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).

  1. Run adb reverse tcp:8081 tcp:8081
  2. You can use Reload JS and other development options with no extra configuration

Configure your app to connect to the local dev server via Wi-Fi #

  1. Make sure your laptop and your phone are on the same Wi-Fi network.
  2. Open your React Native app on your device. You can do this the same way you'd open any other app.
  3. You'll see a red screen with an error. This is OK. The following steps will fix that.
  4. Open the Developer menu by shaking the device or running adb shell input keyevent 82 from the command line.
  5. Go to Dev Settings.
  6. Go to Debug server host for device.
  7. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). On Mac, you can find the IP address in System Preferences / Network. On Windows, open the command prompt and type ipconfig to find your machine's IP address (more info).
  8. Go back to the Developer menu and select Reload JS.
© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/running-on-device-ios.html b/docs/running-on-device-ios.html index b1e4220a841..d080a5bae44 100644 --- a/docs/running-on-device-ios.html +++ b/docs/running-on-device-ios.html @@ -1,4 +1,4 @@ -Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Note that running on device requires Apple Developer account and provisioning your iPhone. This guide covers only React Native specific topic.

Accessing development server from device #

You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Change the IP in the URL from localhost to your laptop's IP. On Mac, you can find the IP address in System Preferences / Network.
  3. In Xcode select your phone as build target and press "Build and run"

Hint

Shake the device to open development menu (reload, debug, etc.)

Using offline bundle #

When you run your app on device, we pack all the JavaScript code and the images used into the app's resources. This way you can test it without development server running and submit the app to the AppStore.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Uncomment jsCodeLocation = [[NSBundle mainBundle] ...
  3. The JS bundle will be built for dev or prod depending on your app's scheme (Debug = development build with warnings, Release = minified prod build with perf optimizations). To change the scheme navigate to Product > Scheme > Edit Scheme... in xcode and change Build Configuration between Debug and Release.

Disabling in-app developer menu #

When building your app for production, your app's scheme should be set to Release as detailed in the debugging documentation in order to disable the in-app developer menu.

Troubleshooting #

If curl command fails make sure the packager is running. Also try adding --ipv4 flag to the end of it.

Note that since v0.14 JS and images are automatically packaged into the iOS app using Bundle React Native code and images Xcode build phase.

© 2016 Facebook Inc.

Running On Device #

Edit on GitHub

Note that running on device requires Apple Developer account and provisioning your iPhone. This guide covers only React Native specific topic.

Accessing development server from device #

You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Change the IP in the URL from localhost to your laptop's IP. On Mac, you can find the IP address in System Preferences / Network.
  3. In Xcode select your phone as build target and press "Build and run"

Hint

Shake the device to open development menu (reload, debug, etc.)

Using offline bundle #

When you run your app on device, we pack all the JavaScript code and the images used into the app's resources. This way you can test it without development server running and submit the app to the AppStore.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Uncomment jsCodeLocation = [[NSBundle mainBundle] ...
  3. The JS bundle will be built for dev or prod depending on your app's scheme (Debug = development build with warnings, Release = minified prod build with perf optimizations). To change the scheme navigate to Product > Scheme > Edit Scheme... in xcode and change Build Configuration between Debug and Release.

Disabling in-app developer menu #

When building your app for production, your app's scheme should be set to Release as detailed in the debugging documentation in order to disable the in-app developer menu.

Troubleshooting #

If curl command fails make sure the packager is running. Also try adding --ipv4 flag to the end of it.

Note that since v0.14 JS and images are automatically packaged into the iOS app using Bundle React Native code and images Xcode build phase.

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/scrollview.html b/docs/scrollview.html index 4105a9aedd1..03382577dac 100644 --- a/docs/scrollview.html +++ b/docs/scrollview.html @@ -1,4 +1,4 @@ -ScrollView – React Native | A framework for building native apps using React

ScrollView #

Edit on GitHub

Component that wraps platform ScrollView while providing +ScrollView – React Native | A framework for building native apps using React

ScrollView #

Edit on GitHub

Component that wraps platform ScrollView while providing integration with touch locking "responder" system.

Keep in mind that ScrollViews must have a bounded height in order to work, since they contain unbounded-height children into a bounded container (via a scroll interaction). In order to bound the height of a ScrollView, either @@ -90,9 +90,12 @@ with snapToAlignment.

ioszoomScale number #

The current scale of the scroll view content. The default value is 1.0.

Examples #

Edit on GitHub
'use strict'; +with horizontal={true}.

ioszoomScale number #

The current scale of the scroll view content. The default value is 1.0.

Methods #

endRefreshing() #

Deprecated. Use RefreshControl instead.

scrollTo(y: number | { x?: number, y?: number, animated?: boolean }, x: number, animated: boolean) #

Scrolls to a given x, y offset, either immediately or with a smooth animation.

Syntax:

scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})

Note: The weird argument signature is due to the fact that, for historical reasons, +the function also accepts separate arguments as as alternative to the options object. +This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.

scrollWithoutAnimationTo(y, x) #

Deprecated, do not use.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { ScrollView, StyleSheet, @@ -100,7 +103,7 @@ with horizontal={true}.

, View, Image -} = React; +} = ReactNative; exports.displayName = (undefined: ?string); exports.title = '<ScrollView>'; @@ -223,6 +226,6 @@ THUMBS = THUMBS \ No newline at end of file diff --git a/docs/segmentedcontrolios.html b/docs/segmentedcontrolios.html index d21222eece5..1dd9a5f99d6 100644 --- a/docs/segmentedcontrolios.html +++ b/docs/segmentedcontrolios.html @@ -1,4 +1,4 @@ -SegmentedControlIOS – React Native | A framework for building native apps using React

SegmentedControlIOS #

Edit on GitHub

Use SegmentedControlIOS to render a UISegmentedControl iOS.

Programmatically changing selected index #

The selected index can be changed on the fly by assigning the +SegmentedControlIOS – React Native | A framework for building native apps using React

SegmentedControlIOS #

Edit on GitHub

Use SegmentedControlIOS to render a UISegmentedControl iOS.

Programmatically changing selected index #

The selected index can be changed on the fly by assigning the selectIndex prop to a state variable, then changing that variable. Note that the state variable would need to be updated as the user selects a value and changes the index, as shown in the example below.

<SegmentedControlIOS @@ -13,13 +13,14 @@ The onValueChange callback will still work as expected.

onValueChange function #

Callback that is called when the user taps a segment; passes the segment's value as an argument

selectedIndex number #

The index in props.values of the segment to be (pre)selected.

tintColor string #

Accent color of the control.

values [string] #

The labels for the control's segment buttons, in order.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { SegmentedControlIOS, Text, View, StyleSheet -} = React; +} = ReactNative; var BasicSegmentedControlExample = React.createClass({ render() { @@ -180,6 +181,6 @@ exports.examples \ No newline at end of file diff --git a/docs/shadowproptypesios.html b/docs/shadowproptypesios.html index 4e8a2fb7788..5316ebc9207 100644 --- a/docs/shadowproptypesios.html +++ b/docs/shadowproptypesios.html @@ -1,4 +1,4 @@ -ShadowPropTypesIOS – React Native | A framework for building native apps using React

ShadowPropTypesIOS #

Edit on GitHub

Props #

shadowColor color #

shadowOffset {width: number, height: number} #

shadowOpacity number #

shadowRadius number #

© 2016 Facebook Inc.

ShadowPropTypesIOS #

Edit on GitHub

Props #

shadowColor color #

shadowOffset {width: number, height: number} #

shadowOpacity number #

shadowRadius number #

© 2016 Facebook Inc.
\ No newline at end of file diff --git a/docs/signed-apk-android.html b/docs/signed-apk-android.html index 7fd69e13761..9de4ab7de9e 100644 --- a/docs/signed-apk-android.html +++ b/docs/signed-apk-android.html @@ -1,4 +1,4 @@ -Generating Signed APK – React Native | A framework for building native apps using React

Generating Signed APK #

Edit on GitHub

To distribute your Android application via Google Play store, you'll need to generate a signed release APK. The Signing Your Applications page on Android Developers documentation describes the topic in detail. This guide covers the process in brief, as well as lists the steps required to packaging the JavaScript bundle.

Generating a signing key #

You can generate a private signing key using keytool.

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This command prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore.

The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.

Note: Remember to keep your keystore file private and never commit it to version control.

Setting up gradle variables #

  1. Place the my-release-key.keystore file under the android/app directory in your project folder.
  2. Edit the file ~/.gradle/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore +Generating Signed APK – React Native | A framework for building native apps using React

Generating Signed APK #

Edit on GitHub

Android requires that all apps be digitally signed with a certificate before they can be installed, so to distribute your Android application via Google Play store, you'll need to generate a signed release APK. The Signing Your Applications page on Android Developers documentation describes the topic in detail. This guide covers the process in brief, as well as lists the steps required to packaging the JavaScript bundle.

Generating a signing key #

You can generate a private signing key using keytool.

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This command prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore.

The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.

Note: Remember to keep your keystore file private and never commit it to version control.

Setting up gradle variables #

  1. Place the my-release-key.keystore file under the android/app directory in your project folder.
  2. Edit the file ~/.gradle/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore MYAPP_RELEASE_KEY_ALIAS=my-key-alias MYAPP_RELEASE_STORE_PASSWORD=***** MYAPP_RELEASE_KEY_PASSWORD=*****

These are going to be global gradle variables, which we can later use in our gradle config to sign our app.

Note: Once you publish the app on the Play Store, you will need to republish your app under a different package name (losing all downloads and ratings) if you want to change the signing key at any point. So backup your keystore and don't forget the passwords.

Adding signing config to your app's gradle config #

Edit the file android/app/build.gradle in your project folder and add the signing config,

... @@ -39,6 +39,6 @@ def enableProguardInReleaseBuilds = \ No newline at end of file diff --git a/docs/slider.html b/docs/slider.html index c2322c8fa30..fc265ac3576 100644 --- a/docs/slider.html +++ b/docs/slider.html @@ -1,4 +1,4 @@ -Slider – React Native | A framework for building native apps using React

Slider #

Edit on GitHub

A component used to select a single value from a range of values.

Props #

disabled bool #

If true the user won't be able to move the slider. +Slider – React Native | A framework for building native apps using React

Slider #

Edit on GitHub

A component used to select a single value from a range of values.

Props #

disabled bool #

If true the user won't be able to move the slider. Default value is false.

maximumValue number #

Initial maximum value of the slider. Default value is 1.

minimumValue number #

Initial minimum value of the slider. Default value is 0.

onSlidingComplete function #

Callback called when the user finishes changing the value (e.g. when the slider is released).

onValueChange function #

Callback continuously called while the user is dragging the slider.

step number #

Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). @@ -13,13 +13,14 @@ rightmost pixel of the image will be stretched to fill the track.

iosthumbImage Image.propTypes.source #

Sets an image for the thumb. Only static images are supported.

iostrackImage Image.propTypes.source #

Assigns a single image for the track. Only static images are supported. The center pixel of the image will be stretched to fill the track.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Slider, Text, StyleSheet, View, -} = React; +} = ReactNative; var SliderExample = React.createClass({ getDefaultProps() { @@ -180,6 +181,6 @@ exports.examples \ No newline at end of file diff --git a/docs/sliderios.html b/docs/sliderios.html index 2bb9f0a3a06..e6c4b28e81e 100644 --- a/docs/sliderios.html +++ b/docs/sliderios.html @@ -1,4 +1,4 @@ -SliderIOS – React Native | A framework for building native apps using React

SliderIOS #

Edit on GitHub

Note: SliderIOS is deprecated and will be removed in the future. Use the cross-platform +SliderIOS – React Native | A framework for building native apps using React

SliderIOS #

Edit on GitHub

Note: SliderIOS is deprecated and will be removed in the future. Use the cross-platform Slider as a drop-in replacement with the same API.

An iOS-specific component used to select a single value from a range of values.

Props #

disabled bool #

If true the user won't be able to move the slider. Default value is false.

maximumTrackImage Image.propTypes.source #

Assigns a maximum track image. Only static images are supported. The leftmost pixel of the image will be stretched to fill the track.

maximumTrackTintColor string #

The color used for the track to the right of the button. Overrides the @@ -14,13 +14,14 @@ and maximumValue, which default to 0 and 1 respectively. Default value is 0.

This is not a controlled component, e.g. if you don't update the value, the component won't be reset to its initial value.

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { SliderIOS, Text, StyleSheet, View, -} = React; +} = ReactNative; var SliderExample = React.createClass({ getInitialState() { @@ -133,6 +134,6 @@ exports.examples \ No newline at end of file diff --git a/docs/statusbar.html b/docs/statusbar.html index 0f371699e75..f6417cd56a7 100644 --- a/docs/statusbar.html +++ b/docs/statusbar.html @@ -1,4 +1,4 @@ -StatusBar – React Native | A framework for building native apps using React

StatusBar #

Edit on GitHub

Component to control the app status bar.

Usage with Navigator #

It is possible to have multiple StatusBar components mounted at the same +StatusBar – React Native | A framework for building native apps using React

StatusBar #

Edit on GitHub

Component to control the app status bar.

Usage with Navigator #

It is possible to have multiple StatusBar components mounted at the same time. The props will be merged in the order the StatusBar components were mounted. One use case is to specify status bar styles per route using Navigator.

<View> <StatusBar @@ -22,16 +22,17 @@ the next render.

Props

hidden bool #

If the status bar is hidden.

androidbackgroundColor color #

The background color of the status bar.

androidtranslucent bool #

If the status bar is translucent. When translucent is set to true, the app will draw under the status bar. This is useful when using a semi transparent status bar color.

iosbarStyle enum('default', 'light-content') #

Sets the color of the status bar text.

iosnetworkActivityIndicatorVisible bool #

If the network activity indicator should be visible.

iosshowHideTransition enum('fade', 'slide') #

The transition effect when showing and hiding the status bar using the hidden -prop. Defaults to 'fade'.

Examples #

Edit on GitHub
'use strict'; +prop. Defaults to 'fade'.

Methods #

static setHidden(hidden: boolean, animation: 'none' | 'fade' | 'slide') #

static setBarStyle(style: 'default' | 'light-content', animated: boolean) #

static setNetworkActivityIndicatorVisible(visible: boolean) #

static setBackgroundColor(color: string, animated: boolean) #

static setTranslucent(translucent: boolean) #

Examples #

Edit on GitHub
'use strict'; -const React = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); const { StatusBar, StyleSheet, Text, TouchableHighlight, View, -} = React; +} = ReactNative; exports.framework = 'React'; exports.title = '<StatusBar>'; @@ -490,6 +491,6 @@ exports.examples \ No newline at end of file diff --git a/docs/statusbarios.html b/docs/statusbarios.html index 1642cbae83a..b98807a8c72 100644 --- a/docs/statusbarios.html +++ b/docs/statusbarios.html @@ -1,13 +1,14 @@ -StatusBarIOS – React Native | A framework for building native apps using React

StatusBarIOS #

Edit on GitHub

Deprecated. Use StatusBar instead.

Methods #

static setStyle(style: StatusBarStyle, animated?: boolean) #

static setHidden(hidden: boolean, animation?: StatusBarAnimation) #

static setNetworkActivityIndicatorVisible(visible: boolean) #

Examples #

Edit on GitHub
'use strict'; +StatusBarIOS – React Native | A framework for building native apps using React

StatusBarIOS #

Edit on GitHub

Deprecated. Use StatusBar instead.

Methods #

static setStyle(style, animated?) #

static setHidden(hidden, animation?) #

static setNetworkActivityIndicatorVisible(visible) #

Examples #

Edit on GitHub
'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, View, Text, TouchableHighlight, StatusBarIOS, -} = React; +} = ReactNative; exports.framework = 'React'; exports.title = 'StatusBarIOS'; @@ -115,6 +116,6 @@ exports.examples \ No newline at end of file diff --git a/docs/style.html b/docs/style.html index 8c59427cfb6..8bc4633ca7e 100644 --- a/docs/style.html +++ b/docs/style.html @@ -1,4 +1,4 @@ -Style – React Native | A framework for building native apps using React

Style #

Edit on GitHub

React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.

+Style – React Native | A framework for building native apps using React

Style #

Edit on GitHub

React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.

Declare Styles #

The way to declare styles in React Native is the following:

var styles = StyleSheet.create({ base: { @@ -51,6 +51,6 @@ apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/stylesheet.html b/docs/stylesheet.html index b1505857adf..5c1e5a80a0b 100644 --- a/docs/stylesheet.html +++ b/docs/stylesheet.html @@ -1,4 +1,4 @@ -StyleSheet – React Native | A framework for building native apps using React

StyleSheet #

Edit on GitHub

A StyleSheet is an abstraction similar to CSS StyleSheets

Create a new StyleSheet:

var styles = StyleSheet.create({ +StyleSheet – React Native | A framework for building native apps using React

StyleSheet #

Edit on GitHub

A StyleSheet is an abstraction similar to CSS StyleSheets

Create a new StyleSheet:

var styles = StyleSheet.create({ container: { borderRadius: 4, borderWidth: 0.5, @@ -17,7 +17,7 @@ easier to understand.
  • Naming the styles is a good way to add meaning to the low level components in the render function.
  • Performance:

    • Making a stylesheet from a style object makes it possible to refer to it by ID instead of creating a new style object every time.
    • It also allows to send the style only once through the bridge. All -subsequent uses are going to refer an id (not implemented yet).

    Methods #

    static create(obj: {[key: string]: any}) #

    Creates a StyleSheet style reference from the given object.

    Properties #

    hairlineWidth: CallExpression #

    This is defined as the width of a thin line on the platform. It can be +subsequent uses are going to refer an id (not implemented yet).

    Methods #

    static create(obj) #

    Creates a StyleSheet style reference from the given object.

    Properties #

    hairlineWidth: CallExpression #

    This is defined as the width of a thin line on the platform. It can be used as the thickness of a border or division between two elements. Example:

    { borderBottomColor: '#bbb', @@ -64,6 +64,6 @@ the alternative use.

    \ No newline at end of file diff --git a/docs/switch.html b/docs/switch.html index bd2313b48b0..828d4a7adc2 100644 --- a/docs/switch.html +++ b/docs/switch.html @@ -1,4 +1,4 @@ -Switch – React Native | A framework for building native apps using React

    Switch #

    Edit on GitHub

    Renders a boolean input.

    This is a controlled component that requires an onValueChange callback that +Switch – React Native | A framework for building native apps using React

    Switch #

    Edit on GitHub

    Renders a boolean input.

    This is a controlled component that requires an onValueChange callback that updates the value prop in order for the component to reflect user actions. If the value prop is not updated, the component will continue to render the supplied value prop instead of the expected result of any user actions.

    @keyword checkbox @@ -6,12 +6,14 @@ the supplied value prop instead of the expected result of any user Default value is false.

    onValueChange function #

    Invoked with the new value when the value changes.

    testID string #

    Used to locate this view in end-to-end tests.

    value bool #

    The value of the switch. If true the switch will be turned on. Default value is false.

    iosonTintColor color #

    Background color when the switch is turned on.

    iosthumbTintColor color #

    Color of the foreground switch grip.

    iostintColor color #

    Background color when the switch is turned off.

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { + Platform, Switch, Text, View -} = React; +} = ReactNative; var BasicSwitchExample = React.createClass({ getInitialState() { @@ -135,7 +137,7 @@ Default value is false.

    < } ]; -if (React.Platform.OS === 'ios') { +if (Platform.OS === 'ios') { examples.push({ title: 'Custom colors can be provided', render(): ReactElement { return <ColorSwitchExample />; } @@ -161,6 +163,6 @@ exports.examples \ No newline at end of file diff --git a/docs/tabbarios-item.html b/docs/tabbarios-item.html index b80e903add9..ee59c814a49 100644 --- a/docs/tabbarios-item.html +++ b/docs/tabbarios-item.html @@ -1,4 +1,4 @@ -TabBarIOS.Item – React Native | A framework for building native apps using React

    TabBarIOS.Item #

    Edit on GitHub

    Props #

    badge string, number #

    Little red bubble that sits at the top right of the icon.

    icon Image.propTypes.source #

    A custom icon for the tab. It is ignored when a system icon is defined.

    onPress function #

    Callback when this tab is being selected, you should change the state of your +TabBarIOS.Item – React Native | A framework for building native apps using React

    TabBarIOS.Item #

    Edit on GitHub

    Props #

    badge string, number #

    Little red bubble that sits at the top right of the icon.

    icon Image.propTypes.source #

    A custom icon for the tab. It is ignored when a system icon is defined.

    onPress function #

    Callback when this tab is being selected, you should change the state of your component to set selected={true}.

    selected bool #

    It specifies whether the children are visible or not. If you see a blank content, you probably forgot to add a selected one.

    selectedIcon Image.propTypes.source #

    A custom icon when the tab is selected. It is ignored when a system icon is defined. If left empty, the icon will be tinted in blue.

    style View#style #

    React style object.

    systemIcon enum('bookmarks', 'contacts', 'downloads', 'favorites', 'featured', 'history', 'more', 'most-recent', 'most-viewed', 'recents', 'search', 'top-rated') #

    Items comes with a few predefined system icons. Note that if you are @@ -20,6 +20,6 @@ is defined.

    \ No newline at end of file diff --git a/docs/tabbarios.html b/docs/tabbarios.html index 641568272f1..4977a591c55 100644 --- a/docs/tabbarios.html +++ b/docs/tabbarios.html @@ -1,12 +1,13 @@ -TabBarIOS – React Native | A framework for building native apps using React

    TabBarIOS #

    Edit on GitHub

    Props #

    barTintColor color #

    Background color of the tab bar

    tintColor color #

    Color of the currently selected tab icon

    translucent bool #

    A Boolean value that indicates whether the tab bar is translucent

    Examples #

    Edit on GitHub
    'use strict'; +TabBarIOS – React Native | A framework for building native apps using React

    TabBarIOS #

    Edit on GitHub

    Props #

    barTintColor color #

    Background color of the tab bar

    tintColor color #

    Color of the currently selected tab icon

    translucent bool #

    A Boolean value that indicates whether the tab bar is translucent

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, TabBarIOS, Text, View, -} = React; +} = ReactNative; var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg=='; @@ -108,6 +109,6 @@ module.exports \ No newline at end of file diff --git a/docs/testing.html b/docs/testing.html index 68a98d8c58d..0d06ad5e4f4 100644 --- a/docs/testing.html +++ b/docs/testing.html @@ -1,4 +1,4 @@ -Testing – React Native | A framework for building native apps using React

    Testing #

    Edit on GitHub

    Running Tests and Contributing #

    The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR.

    We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!

    Jest Tests #

    Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with

    npm test

    from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

    Note: In order to run your own tests, you will have to first follow the Getting Started instructions on the Jest page and then include the jest objects below in package.json so that the scripts are pre-processed before execution.

    ... +Testing – React Native | A framework for building native apps using React

    Testing #

    Edit on GitHub

    Running Tests and Contributing #

    The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR.

    We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!

    Jest Tests #

    Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with

    npm test

    from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

    Note: In order to run your own tests, you will have to first follow the Getting Started instructions on the Jest page and then include the jest objects below in package.json so that the scripts are pre-processed before execution.

    ... "scripts": { ... "test": "jest" @@ -35,6 +35,6 @@ apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/text.html b/docs/text.html index 4ea6276abc9..54e5395754e 100644 --- a/docs/text.html +++ b/docs/text.html @@ -1,4 +1,4 @@ -Text – React Native | A framework for building native apps using React

    Text #

    Edit on GitHub

    A React component for displaying text which supports nesting, +Text – React Native | A framework for building native apps using React

    Text #

    Edit on GitHub

    A React component for displaying text which supports nesting, styling, and touch handling. In the following example, the nested title and body text will inherit the fontFamily from styles.baseText, but the title provides its own additional styles. The title and body will stack on top of @@ -27,7 +27,7 @@ each other on account of the literal newlines:

    onLayout function #

    Invoked on mount and layout changes with

    {nativeEvent: {layout: {x, y, width, height}}}

    onPress function #

    This function is called on press.

    style style #

    color color
    fontFamily string
    fontSize number
    fontStyle enum('normal', 'italic')
    fontWeight enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')

    Specifies font weight. The values 'normal' and 'bold' are supported for most fonts. Not all fonts have a variant for each of the numeric values, -in that case the closest one is chosen.

    lineHeight number
    textAlign enum('auto', 'left', 'right', 'center', 'justify')

    Specifies text alignment. The value 'justify' is only supported on iOS.

    textShadowColor color
    textShadowOffset {width: number, height: number}
    textShadowRadius number
    androidtextAlignVertical enum('auto', 'top', 'bottom', 'center')
    iosletterSpacing number
    iostextDecorationColor color
    iostextDecorationLine enum('none', 'underline', 'line-through', 'underline line-through')
    iostextDecorationStyle enum('solid', 'double', 'dotted', 'dashed')
    ioswritingDirection enum('auto', 'ltr', 'rtl')

    testID string #

    Used to locate this view in end-to-end tests.

    iosallowFontScaling bool #

    Specifies should fonts scale to respect Text Size accessibility setting on iOS.

    iossuppressHighlighting bool #

    When true, no visual change is made when text is pressed down. By +in that case the closest one is chosen.

    lineHeight number
    textAlign enum('auto', 'left', 'right', 'center', 'justify')

    Specifies text alignment. The value 'justify' is only supported on iOS.

    textDecorationLine enum('none', 'underline', 'line-through', 'underline line-through')
    textShadowColor color
    textShadowOffset {width: number, height: number}
    textShadowRadius number
    androidtextAlignVertical enum('auto', 'top', 'bottom', 'center')
    iosletterSpacing number
    iostextDecorationColor color
    iostextDecorationStyle enum('solid', 'double', 'dotted', 'dashed')
    ioswritingDirection enum('auto', 'ltr', 'rtl')

    testID string #

    Used to locate this view in end-to-end tests.

    iosallowFontScaling bool #

    Specifies should fonts scale to respect Text Size accessibility setting on iOS.

    iossuppressHighlighting bool #

    When true, no visual change is made when text is pressed down. By default, a gray oval highlights the text on press down.

    Description #

    Edit on GitHub

    Nested Text #

    In iOS, the way to display formatted text is by using NSAttributedString: you give the text that you want to display and annotate ranges with some specific formatting. In practice, this is very tedious. For React Native, we decided to use web paradigm for this where you can nest text to achieve the same effect.

    <Text style={{fontWeight: 'bold'}}> I am bold <Text style={{color: 'red'}}> @@ -35,7 +35,7 @@ default, a gray oval highlights the text on press down.

    /Text> </Text>

    Behind the scenes, this is going to be converted to a flat NSAttributedString that contains the following information

    "I am bold and red" 0-9: bold -9-17: bold, red

    Containers #

    The <Text> element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a <Text> are no longer rectangles, but wrap when they see the end of the line.

    <Text> +9-17: bold, red

    Containers #

    The <Text> element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a <Text> are no longer rectangles, but wrap when they see the end of the line.

    <Text> <Text>First part and </Text> <Text>second part</Text> </Text> @@ -90,6 +90,6 @@ html { apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/textinput.html b/docs/textinput.html index 5aeffbc2037..d28659ea187 100644 --- a/docs/textinput.html +++ b/docs/textinput.html @@ -1,4 +1,4 @@ -TextInput – React Native | A framework for building native apps using React

    TextInput #

    Edit on GitHub

    A foundational component for inputting text into the app via a +TextInput – React Native | A framework for building native apps using React

    TextInput #

    Edit on GitHub

    A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto-correction, auto-capitalization, placeholder text, and different keyboard types, such as a numeric keypad.

    The simplest use case is to plop down a TextInput and subscribe to the @@ -40,7 +40,7 @@ true to be able to fill the lines.

    ioskeyboardAppearance enum('default', 'light', 'dark') #

    Determines the color of the keyboard.

    iosonKeyPress function #

    Callback that is called when a key is pressed. Pressed key value is passed as an argument to the callback handler. Fires before onChange callbacks.

    iosreturnKeyType enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') #

    Determines how the return key should look.

    iosselectionState DocumentSelectionState #

    See DocumentSelectionState.js, some state that is responsible for -maintaining selection information for a document

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/docs/timepickerandroid.html b/docs/timepickerandroid.html index eef7b7613ea..92ce1e6dea2 100644 --- a/docs/timepickerandroid.html +++ b/docs/timepickerandroid.html @@ -1,15 +1,15 @@ -TimePickerAndroid – React Native | A framework for building native apps using React

    TimePickerAndroid #

    Edit on GitHub

    Opens the standard Android time picker dialog.

    Example #

    try { +TimePickerAndroid – React Native | A framework for building native apps using React

    TimePickerAndroid #

    Edit on GitHub

    Opens the standard Android time picker dialog.

    Example #

    try { const {action, hour, minute} = await TimePickerAndroid.open({ hour: 14, minute: 0, is24Hour: false, // Will display '2 PM' }); - if (action !== DatePickerAndroid.dismissedAction) { + if (action !== TimePickerAndroid.dismissedAction) { // Selected hour (0-23), minute (0-59) } } catch ({code, message}) { console.warn('Cannot open time picker', message); -}

    Methods #

    static open(options: Object) #

    Opens the standard Android time picker dialog.

    The available keys for the options object are: +}

    Methods #

    static open(options) #

    Opens the standard Android time picker dialog.

    The available keys for the options object are: hour (0-23) - the hour to show, defaults to the current time minute (0-59) - the minute to show, defaults to the current time * is24Hour (boolean) - If true, the picker uses the 24-hour format. If false, @@ -19,13 +19,14 @@ still be resolved with action being TimePickerAndroid.dismissedAction and all the other keys being undefined. Always check whether the action before reading the values.

    static timeSetAction() #

    A time has been selected.

    static dismissedAction() #

    The dialog has been dismissed.

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { TimePickerAndroid, StyleSheet, Text, TouchableWithoutFeedback, -} = React; +} = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); @@ -130,6 +131,6 @@ module.exports \ No newline at end of file diff --git a/docs/timers.html b/docs/timers.html index bb5963b73cf..0bb54825798 100644 --- a/docs/timers.html +++ b/docs/timers.html @@ -1,4 +1,4 @@ -Timers – React Native | A framework for building native apps using React

    Timers #

    Edit on GitHub

    Timers are an important part of an application and React Native implements the browser timers.

    Timers #

    • setTimeout, clearTimeout
    • setInterval, clearInterval
    • setImmediate, clearImmediate
    • requestAnimationFrame, cancelAnimationFrame

    requestAnimationFrame(fn) is not the same as setTimeout(fn, 0) - the former will fire after all the frame has flushed, whereas the latter will fire as quickly as possible (over 1000x per second on a iPhone 5S).

    setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.

    The Promise implementation uses setImmediate as its asynchronicity primitive.

    InteractionManager #

    One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.

    Applications can schedule tasks to run after interactions with the following:

    InteractionManager.runAfterInteractions(() => { +Timers – React Native | A framework for building native apps using React

    Timers #

    Edit on GitHub

    Timers are an important part of an application and React Native implements the browser timers.

    Timers #

    • setTimeout, clearTimeout
    • setInterval, clearInterval
    • setImmediate, clearImmediate
    • requestAnimationFrame, cancelAnimationFrame

    requestAnimationFrame(fn) is not the same as setTimeout(fn, 0) - the former will fire after all the frame has flushed, whereas the latter will fire as quickly as possible (over 1000x per second on a iPhone 5S).

    setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.

    The Promise implementation uses setImmediate as its asynchronicity primitive.

    InteractionManager #

    One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.

    Applications can schedule tasks to run after interactions with the following:

    InteractionManager.runAfterInteractions(() => { // ...long-running synchronous task... });

    Compare this to other scheduling alternatives:

    • requestAnimationFrame(): for code that animates a view over time.
    • setImmediate/setTimeout/setInterval(): run code later, note this may delay animations.
    • runAfterInteractions(): run code later, without delaying active animations.

    The touch handling system considers one or more active touches to be an 'interaction' and will delay runAfterInteractions() callbacks until all touches have ended or been cancelled.

    InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

    var handle = InteractionManager.createInteractionHandle(); // run animation... (`runAfterInteractions` tasks are queued) @@ -30,6 +30,6 @@ apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/toastandroid.html b/docs/toastandroid.html index 7846ee10586..49077045274 100644 --- a/docs/toastandroid.html +++ b/docs/toastandroid.html @@ -1,13 +1,14 @@ -ToastAndroid – React Native | A framework for building native apps using React

    ToastAndroid #

    Edit on GitHub

    This exposes the native ToastAndroid module as a JS module. This has a function 'show' -which takes the following parameters:

    1. String message: A string with the text to toast
    2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG

    Methods #

    static show(message: string, duration: number) #

    Properties #

    SHORT: MemberExpression #

    LONG: MemberExpression #

    Examples #

    Edit on GitHub
    'use strict'; +ToastAndroid – React Native | A framework for building native apps using React

    ToastAndroid #

    Edit on GitHub

    This exposes the native ToastAndroid module as a JS module. This has a function 'show' +which takes the following parameters:

    1. String message: A string with the text to toast
    2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG

    Methods #

    static show(message, duration) #

    Properties #

    SHORT: MemberExpression #

    LONG: MemberExpression #

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, Text, ToastAndroid, TouchableWithoutFeedback, -} = React; +} = ReactNative; var UIExplorerBlock = require('UIExplorerBlock'); var UIExplorerPage = require('UIExplorerPage'); @@ -67,6 +68,6 @@ module.exports \ No newline at end of file diff --git a/docs/toolbarandroid.html b/docs/toolbarandroid.html index ab10f30a65e..5306215e556 100644 --- a/docs/toolbarandroid.html +++ b/docs/toolbarandroid.html @@ -1,4 +1,4 @@ -ToolbarAndroid – React Native | A framework for building native apps using React

    ToolbarAndroid #

    Edit on GitHub

    React component that wraps the Android-only Toolbar widget. A Toolbar can display a logo, +ToolbarAndroid – React Native | A framework for building native apps using React

    ToolbarAndroid #

    Edit on GitHub

    React component that wraps the Android-only Toolbar widget. A Toolbar can display a logo, navigation icon (e.g. hamburger menu), a title & subtitle and a list of actions. The title and subtitle are expanded so the logo and navigation icons are displayed on the left, title and subtitle in the middle and the actions on the right.

    If the toolbar has an only child, it will be displayed between the title and actions.

    Although the Toolbar supports remote images for the logo, navigation and action icons, this @@ -33,12 +33,13 @@ In addition to this property you need to add

    android:supportsRtl="t setLayoutDirection(LayoutDirection.RTL) in your MainActivity onCreate method.

    subtitle string #

    Sets the toolbar subtitle.

    subtitleColor color #

    Sets the toolbar subtitle color.

    testID string #

    Used to locate this view in end-to-end tests.

    title string #

    Sets the toolbar title.

    titleColor color #

    Sets the toolbar title color.

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, Text, View, -} = React; +} = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); @@ -164,6 +165,6 @@ module.exports \ No newline at end of file diff --git a/docs/touchablehighlight.html b/docs/touchablehighlight.html index e245bbfd077..509c4509ee4 100644 --- a/docs/touchablehighlight.html +++ b/docs/touchablehighlight.html @@ -1,4 +1,4 @@ -TouchableHighlight – React Native | A framework for building native apps using React

    TouchableHighlight #

    Edit on GitHub

    A wrapper for making views respond properly to touches. +TouchableHighlight – React Native | A framework for building native apps using React

    TouchableHighlight #

    Edit on GitHub

    A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, which allows the underlay color to show through, darkening or tinting the view. The underlay comes from adding a view to the view hierarchy, which can sometimes @@ -30,6 +30,6 @@ active.

    \ No newline at end of file diff --git a/docs/touchablenativefeedback.html b/docs/touchablenativefeedback.html index c9de460209c..0f0c98019a4 100644 --- a/docs/touchablenativefeedback.html +++ b/docs/touchablenativefeedback.html @@ -1,4 +1,4 @@ -TouchableNativeFeedback – React Native | A framework for building native apps using React

    TouchableNativeFeedback #

    Edit on GitHub

    A wrapper for making views respond properly to touches (Android only). +TouchableNativeFeedback – React Native | A framework for building native apps using React

    TouchableNativeFeedback #

    Edit on GitHub

    A wrapper for making views respond properly to touches (Android only). On Android this component uses native state drawable to display touch feedback. At the moment it only supports having a single View instance as a child node, as it's implemented by replacing that View with another instance @@ -15,18 +15,15 @@ of RCTView node with some additional properties set.

    Background drawable o ); },

    Props #

    background backgroundPropType #

    Determines the type of background drawable that's going to be used to display feedback. It takes an object with type property and extra data -depending on the type. It's recommended to use one of the following -static methods to generate that dictionary:

    1) TouchableNativeFeedback.SelectableBackground() - will create object -that represents android theme's default background for selectable -elements (?android:attr/selectableItemBackground)

    2) TouchableNativeFeedback.SelectableBackgroundBorderless() - will create -object that represent android theme's default background for borderless +depending on the type. It's recommended to use one of the static +methods to generate that dictionary.

    Methods #

    static SelectableBackground() #

    Creates an object that represents android theme's default background for +selectable elements (?android:attr/selectableItemBackground).

    static SelectableBackgroundBorderless() #

    Creates an object that represent android theme's default background for borderless selectable elements (?android:attr/selectableItemBackgroundBorderless). -Available on android API level 21+

    3) TouchableNativeFeedback.Ripple(color, borderless) - will create -object that represents ripple drawable with specified color (as a +Available on android API level 21+.

    static Ripple(color: string, borderless: boolean) #

    Creates an object that represents ripple drawable with specified color (as a string). If property borderless evaluates to true the ripple will render outside of the view bounds (see native actionbar buttons as an example of that behavior). This background type is available on Android -API level 21+

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/docs/touchableopacity.html b/docs/touchableopacity.html index 4f679f1585a..9d8dd915e1e 100644 --- a/docs/touchableopacity.html +++ b/docs/touchableopacity.html @@ -1,4 +1,4 @@ -TouchableOpacity – React Native | A framework for building native apps using React

    TouchableOpacity #

    Edit on GitHub

    A wrapper for making views respond properly to touches. +TouchableOpacity – React Native | A framework for building native apps using React

    TouchableOpacity #

    Edit on GitHub

    A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, dimming it. This is done without actually changing the view hierarchy, and in general is easy to add to an app without weird side-effects.

    Example:

    renderButton: function() { @@ -11,7 +11,7 @@ easy to add to an app without weird side-effects.

    Example:

    /TouchableOpacity> ); },

    Props #

    activeOpacity number #

    Determines what the opacity of the wrapped view should be when touch is -active.

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/docs/touchablewithoutfeedback.html b/docs/touchablewithoutfeedback.html index 73edf9e5db8..75628ca141e 100644 --- a/docs/touchablewithoutfeedback.html +++ b/docs/touchablewithoutfeedback.html @@ -1,4 +1,4 @@ -TouchableWithoutFeedback – React Native | A framework for building native apps using React

    TouchableWithoutFeedback #

    Edit on GitHub

    Do not use unless you have a very good reason. All the elements that +TouchableWithoutFeedback – React Native | A framework for building native apps using React

    TouchableWithoutFeedback #

    Edit on GitHub

    Do not use unless you have a very good reason. All the elements that respond to press should have a visual feedback when touched. This is one of the primary reason a "web" app doesn't feel "native".

    NOTE: TouchableWithoutFeedback supports only one child

    If you wish to have several child components, wrap them in a View.

    Props #

    accessibilityComponentType View.AccessibilityComponentType #

    accessibilityTraits View.AccessibilityTraits, [object Object] #

    accessible bool #

    delayLongPress number #

    Delay in ms, from onPressIn, before onLongPress is called.

    delayPressIn number #

    Delay in ms, from the start of the touch, before onPressIn is called.

    delayPressOut number #

    Delay in ms, from the release of the touch, before onPressOut is called.

    disabled bool #

    If true, disable all interactions for this component.

    hitSlop {top: number, left: number, bottom: number, right: number} #

    This defines how far your touch can start away from the button. This is added to pressRetentionOffset when moving off of the button. @@ -26,6 +26,6 @@ is disabled. Ensure you pass in a constant to reduce memory allocations.

    \ No newline at end of file diff --git a/docs/transforms.html b/docs/transforms.html index c1f3f2f3950..b86312550ab 100644 --- a/docs/transforms.html +++ b/docs/transforms.html @@ -1,4 +1,4 @@ -Transforms – React Native | A framework for building native apps using React

    Transforms #

    Edit on GitHub

    Props #

    transform [{perspective: number}, {rotate: string}, {rotateX: string}, {rotateY: string}, {rotateZ: string}, {scale: number}, {scaleX: number}, {scaleY: number}, {translateX: number}, {translateY: number}, {skewX: string}, {skewY: string}] #

    transformMatrix TransformMatrixPropType #

    © 2016 Facebook Inc.

    Transforms #

    Edit on GitHub

    Props #

    transform [{perspective: number}, {rotate: string}, {rotateX: string}, {rotateY: string}, {rotateZ: string}, {scale: number}, {scaleX: number}, {scaleY: number}, {translateX: number}, {translateY: number}, {skewX: string}, {skewY: string}] #

    transformMatrix TransformMatrixPropType #

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html index 421a50629a5..9db6ccd9845 100644 --- a/docs/troubleshooting.html +++ b/docs/troubleshooting.html @@ -1,4 +1,4 @@ -Troubleshooting – React Native | A framework for building native apps using React

    Troubleshooting #

    Edit on GitHub

    Cmd-R does not reload the simulator #

    Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.

    Keyboard Menu

    If you are using a non-QWERTY/AZERTY keyboard layout you can use the Hardware > Shake Gesture to bring up the dev menu and click "Refresh"

    Port already in use red-screen #

    red-screen

    Something is probably already running on port 8081. You can either kill it or try to change which port the packager is listening to.

    Kill process on port 8081 #

    $ sudo lsof -n -i4TCP:8081 | grep LISTEN

    then

    $ kill -9 <cma process id>

    Change the port in Xcode #

    Edit AppDelegate.m to use a different port.

    // OPTION 1 +Troubleshooting – React Native | A framework for building native apps using React

    Troubleshooting #

    Edit on GitHub

    Cmd-R does not reload the simulator #

    Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.

    Keyboard Menu

    If you are using a non-QWERTY/AZERTY keyboard layout you can use the Hardware > Shake Gesture to bring up the dev menu and click "Refresh". Alternatively, you can hit Cmd-P on Dvorak/Colemak layouts to reload the simulator.

    Port already in use red-screen #

    red-screen

    Something is probably already running on port 8081. You can either kill it or try to change which port the packager is listening to.

    Kill process on port 8081 #

    $ sudo lsof -n -i4TCP:8081 | grep LISTEN

    then

    $ kill -9 <cma process id>

    Change the port in Xcode #

    Edit AppDelegate.m to use a different port.

    // OPTION 1 // Load from development server. Start the server from the repository root: // // $ npm start @@ -29,6 +29,6 @@ import Firebase from 'firebase' \ No newline at end of file diff --git a/docs/tutorial.html b/docs/tutorial.html index f792b1b9163..db883caec2a 100644 --- a/docs/tutorial.html +++ b/docs/tutorial.html @@ -1,8 +1,10 @@ -Tutorial – React Native | A framework for building native apps using React

    Tutorial #

    Edit on GitHub

    Preface #

    This tutorial aims to get you up to speed with writing iOS and Android apps using React Native. If you're wondering what React Native is and why Facebook built it, this blog post explains that.

    We assume you have experience writing applications with React. If not, you can learn about it on the React website.

    Building a real-world app #

    This tutorial explains how to build a simple app to get you started. If you're looking for a more advanced tutorial on building a real-world app, check out makeitopen.com.

    Setup #

    React Native requires the basic setup explained at React Native Getting Started.

    After installing these dependencies there are two simple commands to get a React Native project all set up for development.

    1. npm install -g react-native-cli

      react-native-cli is a command line interface that does the rest of the set up. It’s installable via npm. This will install react-native as a command in your terminal. You only ever need to do this once.

    2. react-native init AwesomeProject

      This command fetches the React Native source code and dependencies and then creates a new Xcode project in AwesomeProject/iOS/AwesomeProject.xcodeproj and a gradle project in AwesomeProject/android/app.

    Overview #

    In this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.

    Starting the app on iOS #

    Open this new project (AwesomeProject/ios/AwesomeProject.xcodeproj) in Xcode and simply build and run it with ⌘+R. Doing so will also start a Node server which enables live code reloading. With this you can see your changes by pressing ⌘+R in the simulator rather than recompiling in Xcode.

    Starting the app on Android #

    In your terminal navigate into the AwesomeProject and run:

    react-native run-android

    This will install the generated app on your emulator or device, as well as start the Node server which enables live code reloading. To see your changes you have to open the rage-shake-menu (either shake the device or press the menu button on devices, press F2 or Page Up for emulator, ⌘+M for Genymotion), and then press Reload JS.

    Hello World #

    react-native init will generate an app with the name of your project, in this case AwesomeProject. This is a simple hello world app. For iOS, you can edit index.ios.js to make changes to the app and then press ⌘+R in the simulator to see the changes. For Android, you can edit index.android.js to make changes to the app and press Reload JS from the rage shake menu to see the changes.

    Mocking data #

    Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the imports, but feel free to add the following constant wherever you like. In index.ios.js or index.android.js :

    var MOCKED_MOVIES_DATA = [ +Tutorial – React Native | A framework for building native apps using React

    Tutorial #

    Edit on GitHub

    Preface #

    This tutorial aims to get you up to speed with writing iOS and Android apps using React Native. If you're wondering what React Native is and why Facebook built it, this blog post explains that.

    We assume you have experience writing applications with React. If not, you can learn about it on the React website.

    Building a real-world app #

    This tutorial explains how to build a simple app to get you started. If you're looking for a more advanced tutorial on building a real-world app, check out makeitopen.com.

    Setup #

    React Native requires the basic setup explained at React Native Getting Started.

    After installing these dependencies there are two simple commands to get a React Native project all set up for development.

    1. npm install -g react-native-cli

      react-native-cli is a command line interface that does the rest of the set up. It’s installable via npm. This will install react-native as a command in your terminal. You only ever need to do this once.

    2. react-native init AwesomeProject

      This command fetches the React Native source code and dependencies and then creates a new Xcode project in AwesomeProject/iOS/AwesomeProject.xcodeproj and a gradle project in AwesomeProject/android/app.

    Overview #

    In this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.

    Starting the app on iOS #

    Open this new project (AwesomeProject/ios/AwesomeProject.xcodeproj) in Xcode and simply build and run it with ⌘+R. Doing so will also start a Node server which enables live code reloading. With this you can see your changes by pressing ⌘+R in the simulator rather than recompiling in Xcode.

    Starting the app on Android #

    In your terminal navigate into the AwesomeProject and run:

    react-native run-android

    This will install the generated app on your emulator or device, as well as start the Node server which enables live code reloading. To see your changes you have to open the rage-shake-menu (either shake the device or press the menu button on devices, press F2 or Page Up for emulator, ⌘+M for Genymotion), and then press Reload JS.

    Hello World #

    react-native init will generate an app with the name of your project, in this case AwesomeProject. This is a simple hello world app. For iOS, you can edit index.ios.js to make changes to the app and then press ⌘+R in the simulator to see the changes. For Android, you can edit index.android.js to make changes to the app and press Reload JS from the rage shake menu to see the changes.

    Mocking data #

    Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the imports, but feel free to add the following constant wherever you like. In index.ios.js or index.android.js :

    var MOCKED_MOVIES_DATA = [ {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}}, ];

    Render a movie #

    We're going to render the title, year, and thumbnail for the movie. Since thumbnail is an Image component in React Native, add Image to the list of React imports below.

    import React, { - AppRegistry, Component, +} from 'react'; +import { + AppRegistry, Image, StyleSheet, Text, @@ -78,7 +80,7 @@ * their very own API that lives in React Native's Github repo. */ var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json';

    Add some initial state to our application so that we can check this.state.movies === null to determine whether the movies data has been loaded or not. We can set this data when the response comes back with this.setState({movies: moviesData}). Add this code just above the render function inside our React class.

    constructor(props) { - super(props); + super(props); this.state = { movies: null, }; @@ -131,8 +133,10 @@

    ListView #

    Let's now modify this application to render all of this data in a ListView component, rather than just rendering the first movie.

    Why is a ListView better than just rendering all of these elements or putting them in a ScrollView? Despite React being fast, rendering a possibly infinite list of elements could be slow. ListView schedules rendering of views so that you only display the ones on screen and those already rendered but off screen are removed from the native view hierarchy.

    First things first: add the ListView import to the top of the file.

    import React, { - AppRegistry, Component, +} from 'react'; +import { + AppRegistry, Image, ListView, StyleSheet, @@ -182,8 +186,10 @@ */ import React, { - AppRegistry, Component, +} from 'react'; +import { + AppRegistry, Image, ListView, StyleSheet, @@ -191,11 +197,7 @@ import React, , } from 'react-native'; -var API_KEY = '7waqfqbprs7pajbz28mqf6vz'; -var API_URL = 'http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json'; -var PAGE_SIZE = 25; -var PARAMS = '?apikey=' + API_KEY + '&page_limit=' + PAGE_SIZE; -var REQUEST_URL = API_URL + PARAMS; +var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json'; class AwesomeProject extends Component { constructor(props) { @@ -309,6 +311,6 @@ AppRegistry. apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/upgrading.html b/docs/upgrading.html index 4f02a5eaefb..d6c7c660370 100644 --- a/docs/upgrading.html +++ b/docs/upgrading.html @@ -1,4 +1,4 @@ -Upgrading – React Native | A framework for building native apps using React

    Upgrading #

    Edit on GitHub

    Upgrading to new versions of React Native will give you access to more APIs, views, developer tools +Upgrading – React Native | A framework for building native apps using React

    Upgrading #

    Edit on GitHub

    Upgrading to new versions of React Native will give you access to more APIs, views, developer tools and other goodies. Because React Native projects are essentially made up of an Android project, an iOS project and a JavaScript project, all combined under an npm package, upgrading can be rather tricky. But we try to make it easy for you. Here's what you need to do to upgrade from an older @@ -22,6 +22,6 @@ template version. If you are unsure, press h to get a list of possi apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/vibration.html b/docs/vibration.html index 12d10a36aa9..d8ab147834c 100644 --- a/docs/vibration.html +++ b/docs/vibration.html @@ -1,15 +1,16 @@ -Vibration – React Native | A framework for building native apps using React

    Vibration #

    Edit on GitHub

    The Vibration API is exposed at Vibration.vibrate(). +Vibration – React Native | A framework for building native apps using React

    Vibration #

    Edit on GitHub

    The Vibration API is exposed at Vibration.vibrate(). The vibration is asynchronous so this method will return immediately.

    There will be no effect on devices that do not support Vibration, eg. the simulator.

    Note for android -add <uses-permission android:name="android.permission.VIBRATE"/> to AndroidManifest.xml

    Vibration patterns are currently unsupported.

    Methods #

    static vibrate(pattern: number | Array<number>, repeat: boolean) #

    static cancel() #

    Stop vibration

    @platform android

    Examples #

    Edit on GitHub
    'use strict'; +add <uses-permission android:name="android.permission.VIBRATE"/> to AndroidManifest.xml

    Vibration patterns are currently unsupported.

    Methods #

    static vibrate(pattern, repeat) #

    static cancel() #

    Stop vibration

    @platform android

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, View, Text, TouchableHighlight, Vibration, -} = React; +} = ReactNative; exports.framework = 'React'; exports.title = 'Vibration'; @@ -98,6 +99,6 @@ exports.examples \ No newline at end of file diff --git a/docs/vibrationios.html b/docs/vibrationios.html index 25d1102b519..75ee336a799 100644 --- a/docs/vibrationios.html +++ b/docs/vibrationios.html @@ -1,16 +1,17 @@ -VibrationIOS – React Native | A framework for building native apps using React

    VibrationIOS #

    Edit on GitHub

    NOTE: VibrationIOS is being deprecated. Use Vibration instead.

    The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this +VibrationIOS – React Native | A framework for building native apps using React

    VibrationIOS #

    Edit on GitHub

    NOTE: VibrationIOS is being deprecated. Use Vibration instead.

    The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this function will trigger a one second vibration. The vibration is asynchronous so this method will return immediately.

    There will be no effect on devices that do not support Vibration, eg. the iOS simulator.

    Vibration patterns are currently unsupported.

    Methods #

    static vibrate() #

    @deprecated

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, View, Text, TouchableHighlight, VibrationIOS -} = React; +} = ReactNative; exports.framework = 'React'; exports.title = 'VibrationIOS'; @@ -55,6 +56,6 @@ exports.examples \ No newline at end of file diff --git a/docs/videos.html b/docs/videos.html index 3d3c6f76264..be8b23a211c 100644 --- a/docs/videos.html +++ b/docs/videos.html @@ -1,4 +1,4 @@ -Videos – React Native | A framework for building native apps using React

    Videos #

    Edit on GitHub

    React.js Conf 2016 #

    +Videos – React Native | A framework for building native apps using React

    Videos #

    Edit on GitHub

    React.js Conf 2016 #

    @@ -62,6 +62,6 @@ This player is only available in HTML5 enabled browsers. Please update your brow apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/view.html b/docs/view.html index a16a7557c04..f69502af4a8 100644 --- a/docs/view.html +++ b/docs/view.html @@ -1,4 +1,4 @@ -View – React Native | A framework for building native apps using React

    View #

    Edit on GitHub

    The most fundamental component for building UI, View is a +View – React Native | A framework for building native apps using React

    View #

    Edit on GitHub

    The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type. View maps directly to the native @@ -97,12 +97,13 @@ it during each frame.

    Rasterization incurs an off-screen drawing pass and memory. Test and measure when using this property.

    Examples #

    Edit on GitHub
    'use strict'; var Platform = require('Platform'); -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, Text, View, -} = React; +} = ReactNative; var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); var styles = StyleSheet.create({ @@ -286,6 +287,6 @@ exports.examples \ No newline at end of file diff --git a/docs/viewpagerandroid.html b/docs/viewpagerandroid.html index 68a782d24b1..9bc8023ecdc 100644 --- a/docs/viewpagerandroid.html +++ b/docs/viewpagerandroid.html @@ -1,4 +1,4 @@ -ViewPagerAndroid – React Native | A framework for building native apps using React

    ViewPagerAndroid #

    Edit on GitHub

    Container that allows to flip left and right between child views. Each +ViewPagerAndroid – React Native | A framework for building native apps using React

    ViewPagerAndroid #

    Edit on GitHub

    Container that allows to flip left and right between child views. Each child view of the ViewPagerAndroid will be treated as a separate page and will be stretched to fill the ViewPagerAndroid.

    It is important all children are <View>s and not composite components. You can set style properties like padding or backgroundColor for each @@ -42,9 +42,13 @@ The page scrolling state can be in 3 states: page scroller is now finishing it's closing or opening animation

    onPageSelected function #

    This callback will be called once ViewPager finish navigating to selected page (when user swipes between pages). The event.nativeEvent object passed to this callback will have following fields: - - position - index of page that has been selected

    Examples #

    Edit on GitHub
    'use strict'; + - position - index of page that has been selected

    pageMargin number #

    Blank space to show between pages. This is only visible while scrolling, pages are still +edge-to-edge.

    Methods #

    setPage(selectedPage: number) #

    A helper function to scroll to a specific page in the ViewPager. +The transition between pages will be animated.

    setPageWithoutAnimation(selectedPage: number) #

    A helper function to scroll to a specific page in the ViewPager. +The transition between pages will be not be animated.

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { Image, StyleSheet, @@ -53,7 +57,7 @@ callback will have following fields: TouchableOpacity, View, ViewPagerAndroid, -} = React; +} = ReactNative; import type { ViewPagerScrollState } from 'ViewPagerAndroid'; @@ -192,6 +196,7 @@ import type { ViewPagerScrollState ={this.onPageScroll} onPageSelected={this.onPageSelected} onPageScrollStateChanged={this.onPageScrollStateChanged} + pageMargin={10} ref={viewPager => { this.viewPager = viewPager; }}> {pages} </ViewPagerAndroid> @@ -306,6 +311,6 @@ module.exports \ No newline at end of file diff --git a/docs/webview.html b/docs/webview.html index b1018c7b5d2..c3a14943b2a 100644 --- a/docs/webview.html +++ b/docs/webview.html @@ -1,4 +1,4 @@ -WebView – React Native | A framework for building native apps using React

    WebView #

    Edit on GitHub

    Renders a native WebView.

    Props #

    automaticallyAdjustContentInsets bool #

    contentInset {top: number, left: number, bottom: number, right: number} #

    html string #

    Deprecated

    Use the source prop instead.

    injectedJavaScript string #

    Sets the JS to be injected when the webpage loads.

    mediaPlaybackRequiresUserAction bool #

    Determines whether HTML5 audio & videos require the user to tap before they can +WebView – React Native | A framework for building native apps using React

    WebView #

    Edit on GitHub

    Renders a native WebView.

    Props #

    automaticallyAdjustContentInsets bool #

    contentInset {top: number, left: number, bottom: number, right: number} #

    html string #

    Deprecated

    Use the source prop instead.

    injectedJavaScript string #

    Sets the JS to be injected when the webpage loads.

    mediaPlaybackRequiresUserAction bool #

    Determines whether HTML5 audio & videos require the user to tap before they can start playing. The default value is false.

    onError function #

    Invoked when load fails

    onLoad function #

    Invoked when load finish

    onLoadEnd function #

    Invoked when load either succeeds or fails

    onLoadStart function #

    Invoked on load start

    onNavigationStateChange function #

    renderError function #

    Function that returns a view to show if there's an error.

    renderLoading function #

    Function that returns a loading indicator.

    scalesPageToFit bool #

    Sets whether the webpage scales to fit the view and the user can change the scale.

    source {uri: string, method: string, headers: object, body: string}, {html: string, baseUrl: string}, number #

    Loads static html or a uri (with optional headers) in the WebView.

    startInLoadingState bool #

    url string #

    Deprecated

    Use the source prop instead.

    androiddomStorageEnabled bool #

    Used on Android only, controls whether DOM Storage is enabled or not

    androidjavaScriptEnabled bool #

    Used on Android only, JS is enabled by default for WebView on iOS

    iosallowsInlineMediaPlayback bool #

    Determines whether HTML5 videos play inline or use the native full-screen controller. default value false @@ -11,9 +11,10 @@ for UIScrollViewDecelerationRateNormal and UIScrollViewDecelerationRateFast respectively. - normal: 0.998 - fast: 0.99 (the default for iOS WebView)

    iosonShouldStartLoadWithRequest function #

    Allows custom handling of any webview requests by a JS handler. Return true -or false from this method to continue loading the request.

    iosscrollEnabled bool #

    Examples #

    Edit on GitHub
    'use strict'; +or false from this method to continue loading the request.

    iosscrollEnabled bool #

    Methods #

    goForward() #

    Go forward one page in the webview's history.

    goBack() #

    Go back one page in the webview's history.

    reload() #

    Reloads the current page.

    getWebViewHandle(): any #

    Returns the native webview node.

    Examples #

    Edit on GitHub
    'use strict'; -var React = require('react-native'); +var React = require('react'); +var ReactNative = require('react-native'); var { StyleSheet, Text, @@ -22,7 +23,7 @@ or false from this method to continue loading the request.

    , View, WebView -} = React; +} = ReactNative; var HEADER = '#3b5998'; var BGWASH = 'rgba(255,255,255,0.8)'; @@ -404,6 +405,6 @@ exports.examples \ No newline at end of file diff --git a/index.html b/index.html index a75b71c5155..cce5779d54f 100644 --- a/index.html +++ b/index.html @@ -1,9 +1,11 @@ -React Native | A framework for building native apps using React
    React Native
    A framework for building native apps using React

    React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

    Native Components

    With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

    // iOS +React Native | A framework for building native apps using React
    React Native
    A framework for building native apps using React

    React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

    Native Components

    With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

    // iOS -import React, { +import React, { Component, - TabBarIOS, - NavigatorIOS +} from 'react'; +import { + TabBarIOS, + NavigatorIOS, } from 'react-native'; class App extends Component { @@ -18,11 +20,13 @@ class App extends } }
    // Android -import React, { +import React, { Component, - DrawerLayoutAndroid, - ProgressBarAndroid, - Text +} from 'react'; +import { + DrawerLayoutAndroid, + ProgressBarAndroid, + Text, } from 'react-native'; class App extends Component { @@ -36,11 +40,13 @@ class App extends } }

    Asynchronous Execution

    All operations between the JavaScript application code and the native platform are performed asynchronously, and the native modules can also make use of additional threads as well. This means we can decode images off of the main thread, save to disk in the background, measure text and compute layouts without blocking the UI, and more. As a result, React Native apps are naturally fluid and responsive. The communication is also fully serializable, which allows us to leverage Chrome Developer Tools to debug the JavaScript while running the complete app, either in the simulator or on a physical device.

    See Debugging.

    Touch Handling

    React Native implements a powerful system to negotiate touches in complex view hierarchies and provides high level components such as TouchableHighlight that integrate properly with scroll views and other elements without any additional configuration.

    // iOS & Android -import React, { +import React, { Component, +} from 'react'; +import { ScrollView, TouchableHighlight, - Text + Text, } from 'react-native'; class TouchDemo extends Component { @@ -55,12 +61,14 @@ class TouchDemo extends } }

    Flexbox and Styling

    Laying out views should be easy, which is why we brought the flexbox layout model from the web to React Native. Flexbox makes it simple to build the most common UI layouts, such as stacked and nested boxes with margin and padding. React Native also supports common web styles, such as fontWeight, and the StyleSheet abstraction provides an optimized mechanism to declare all your styles and layout right along with the components that use them and apply them inline.

    // iOS & Android -var React, { +import React, { Component, - Image, - StyleSheet, - Text, - View +} from 'react'; +import { + Image, + StyleSheet, + Text, + View, } from 'react-native'; class ReactNative extends Component { @@ -91,9 +99,11 @@ class ReactNative extends : { fontSize: 10 }, });

    Polyfills

    React Native is focused on changing the way view code is written. For the rest, we look to the web for universal standards and polyfill those APIs where appropriate. You can use npm to install JavaScript libraries that work on top of the functionality baked into React Native, such as XMLHttpRequest, window.requestAnimationFrame, and navigator.geolocation. We are working on expanding the available APIs, and are excited for the Open Source community to contribute as well.

    // iOS & Android -import React, { +import React, { Component, - Text +} from 'react'; +import { + Text, } from 'react-native'; class GeoInfo extends Component { @@ -134,8 +144,10 @@ class GeoInfo extends , { Component, +} from 'react'; +import { NativeModules, - Text + Text, } from 'react-native'; class Message extends Component { @@ -172,9 +184,11 @@ class Message extends RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString); @end
    // JavaScript -import React, { +import React, { Component, - requireNativeComponent +} from 'react'; +import { + requireNativeComponent, } from 'react-native'; var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); @@ -201,8 +215,10 @@ public class MyCustomModule extends import React, { Component, +} from 'react'; +import { NativeModules, - Text + Text, } from 'react-native'; class Message extends Component { constructor(props) { @@ -242,7 +258,9 @@ public class MyCustomViewManager extends < import React, { Component, - requireNativeComponent +} from 'react'; +import { + requireNativeComponent, } from 'react-native'; var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); @@ -271,6 +289,6 @@ export default class MyCustomView extends apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/releases/0.25/docs/actionsheetios.html b/releases/0.25/docs/actionsheetios.html index b5028c6f0d0..6f8ea238073 100644 --- a/releases/0.25/docs/actionsheetios.html +++ b/releases/0.25/docs/actionsheetios.html @@ -211,7 +211,7 @@ exports.examples return <ShareScreenshotExample />; } } -];
    © 2016 Facebook Inc.

    Debugging #

    Edit on GitHub

    Debugging React Native Apps #

    To access the in-app developer menu:

    1. On iOS shake the device or press control + ⌘ + z in the simulator.
    2. On Android shake the device or press hardware menu button (available on older devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.

    Hint

    To disable the developer menu for production builds:

    1. For iOS open your project in Xcode and select ProductSchemeEdit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.
    2. For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gradle assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.

    Android logging #

    Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.

    Reload #

    Selecting Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.

    YellowBox/RedBox #

    Using console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.

    You can use console.error to display a full screen error on a red background.

    These boxes only appear when you're running your app in dev mode.

    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.

    In Chrome, press ⌘ + option + i or select ViewDeveloperDeveloper Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.

    To debug on a real device:

    1. On iOS - open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
    2. On Android, if you're running Android 5.0+ device connected via USB you can use adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

    Custom JavaScript debugger #

    To use a custom JavaScript debugger define the REACT_DEBUGGER environment variable to a command that will start your custom debugger. That variable will be read from the Packager process. If that environment variable is set, selecting Debug JS Remotely from the developer menu will execute that command instead of opening Chrome. The exact command to be executed is the contents of the REACT_DEBUGGER environment variable followed by the space separated paths of all project roots (e.g. 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 end up being executed). Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.

    Live Reload #

    This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option:

    1. On iOS, select Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.
    2. On Android, launch dev menu, go to Dev Settings and select Auto reload on JS change option

    FPS (Frames per Second) Monitor #

    On 0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.

    © 2016 Facebook Inc.

    Debugging #

    Edit on GitHub

    Debugging React Native Apps #

    To access the in-app developer menu:

    1. On iOS shake the device or press control + ⌘ + z in the simulator.
    2. On Android shake the device or press hardware menu button (available on older devices and in most of the emulators, e.g. in genymotion you can press ⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.

    Hint

    To disable the developer menu for production builds:

    1. For iOS open your project in Xcode and select ProductSchemeEdit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.
    2. For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gradle assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.

    Android logging #

    Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.

    Reload #

    Selecting Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.

    YellowBox/RedBox #

    Using console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.

    You can use console.error to display a full screen error on a red background.

    By default, the warning box is enabled in __DEV__. Set the following flag to disable it:

    console.disableYellowBox = true; +console.warn('YellowBox is disabled.');

    Specific warnings can be ignored programmatically by setting the array:

    console.ignoredYellowBox = ['Warning: ...'];

    Strings in console.ignoredYellowBox can be a prefix of the warning that should be ignored.

    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.

    In Chrome, press ⌘ + option + i or select ViewDeveloperDeveloper Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.

    To debug on a real device:

    1. On iOS - open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
    2. On Android, if you're running Android 5.0+ device connected via USB you can use adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

    Custom JavaScript debugger #

    To use a custom JavaScript debugger define the REACT_DEBUGGER environment variable to a command that will start your custom debugger. That variable will be read from the Packager process. If that environment variable is set, selecting Debug JS Remotely from the developer menu will execute that command instead of opening Chrome. The exact command to be executed is the contents of the REACT_DEBUGGER environment variable followed by the space separated paths of all project roots (e.g. 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 end up being executed). Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.

    Live Reload #

    This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option:

    1. On iOS, select Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.
    2. On Android, launch dev menu, go to Dev Settings and select Auto reload on JS change option

    FPS (Frames per Second) Monitor #

    On 0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.

    © 2016 Facebook Inc.

    React Native Versions

    React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

    masterDocs
    0.25-rcDocsRelease Notes
    (current) 0.24DocsRelease Notes
    0.23DocsRelease Notes
    0.22DocsRelease Notes
    0.21DocsRelease Notes
    0.20DocsRelease Notes
    0.19DocsRelease Notes
    0.18DocsRelease Notes
    © 2016 Facebook Inc.

    React Native Versions

    React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

    masterDocs
    0.26-rcDocsRelease Notes
    (current) 0.25DocsRelease Notes
    0.24DocsRelease Notes
    0.23DocsRelease Notes
    0.22DocsRelease Notes
    0.21DocsRelease Notes
    0.20DocsRelease Notes
    0.19DocsRelease Notes
    0.18DocsRelease Notes
    © 2016 Facebook Inc.

    Apps using React Native

    The following is a list of some of the public apps using React Native and are published on the Apple App Store or the Google Play Store. Not all are implemented 100% in React Native -- many are hybrid native/React Native. Can you tell which parts are which? :)

    Want to add your app? Found an app that no longer works or no longer uses React Native? Please submit a pull request on GitHub to update this page!

    Featured Apps

    These are some of the most well-crafted React Native apps that we have come across.
    Be sure to check them out to get a feel for what React Native is capable of!

    All Apps

    Not all apps can be featured, otherwise we would have to create some other category like "super featured" and that's just silly. But that doesn't mean you shouldn't check these apps out!

    breathe Meditation Timer

    breathe Meditation Timer

    iOS -Android

    By idearockers UG

    Bulut Filo Yönetimi

    Bulut Filo Yönetimi

    iOS -Android

    By Macellan.net

    CANDDi

    CANDDi

    iOS -Android

    By CANDDi LTD.

    Chillin'

    Chillin'

    iOS -Android

    By Chillin LLC

    DockMan

    DockMan

    iOS -Android

    By Genki Takiuchi (s21g Inc.)

    Blog post

    Eat or Not

    Eat or Not

    iOS -Android

    By Sharath Prabhal

    Fixt

    Fixt

    iOS -Android

    By Fixt

    Hover

    Hover

    iOS -Android

    By KevinEJohn

    Kakapo

    Kakapo

    iOS -Android

    By Daniel Levitt

    MaxReward - Android

    MaxReward - Android

    iOS -Android

    By Neil Ma

    Mobabuild

    Mobabuild

    iOS -Android

    By Sercan Demircan ( @sercanov )

    ShareHows

    ShareHows

    iOS -Android

    By Dobbit Co., Ltd.

    TeamWarden

    TeamWarden

    iOS -Android

    By nittygritty.net

    uSwitch - Energy switching app

    uSwitch - Energy switching app

    iOS -Android

    By uSwitch Ltd

    Video

    WEARVR

    WEARVR

    iOS -Android

    By WEARVR LLC

    天才段子手

    天才段子手

    iOS -Android

    By Ran Zhao&Ji Zhao

    うたよみん

    うたよみん

    iOS -Android

    By Takayuki IMAI

    © 2016 Facebook Inc.

    Apps using React Native

    The following is a list of some of the public apps using React Native and are published on the Apple App Store or the Google Play Store. Not all are implemented 100% in React Native -- many are hybrid native/React Native. Can you tell which parts are which? :)

    Want to add your app? Found an app that no longer works or no longer uses React Native? Please submit a pull request on GitHub to update this page!

    Featured Apps

    These are some of the most well-crafted React Native apps that we have come across.
    Be sure to check them out to get a feel for what React Native is capable of!

    All Apps

    Not all apps can be featured, otherwise we would have to create some other category like "super featured" and that's just silly. But that doesn't mean you shouldn't check these apps out!

    Azendoo

    Azendoo

    iOS -Android

    By Azendoo

    Blog post

    Blueprint

    Blueprint

    iOS -Android

    By Tom Hayden

    breathe Meditation Timer

    breathe Meditation Timer

    iOS -Android

    By idearockers UG

    Bulut Filo Yönetimi

    Bulut Filo Yönetimi

    iOS -Android

    By Macellan.net

    CANDDi

    CANDDi

    iOS -Android

    By CANDDi LTD.

    Chillin'

    Chillin'

    iOS -Android

    By Chillin LLC

    DockMan

    DockMan

    iOS -Android

    By Genki Takiuchi (s21g Inc.)

    Blog post

    Eat or Not

    Eat or Not

    iOS -Android

    By Sharath Prabhal

    Fixt

    Fixt

    iOS -Android

    By Fixt

    Hover

    Hover

    iOS -Android

    By KevinEJohn

    Kakapo

    Kakapo

    iOS -Android

    By Daniel Levitt

    MaxReward - Android

    MaxReward - Android

    iOS -Android

    By Neil Ma

    Mobabuild

    Mobabuild

    iOS -Android

    By Sercan Demircan ( @sercanov )

    ShareHows

    ShareHows

    iOS -Android

    By Dobbit Co., Ltd.

    TeamWarden

    TeamWarden

    iOS -Android

    By nittygritty.net

    uSwitch - Energy switching app

    uSwitch - Energy switching app

    iOS -Android

    By uSwitch Ltd

    Video

    WEARVR

    WEARVR

    iOS -Android

    By WEARVR LLC

    YAMU

    YAMU

    iOS -Android

    By YAMU (Private) Limited (@yamulk)

    天才段子手

    天才段子手

    iOS -Android

    By Ran Zhao&Ji Zhao

    うたよみん

    うたよみん

    iOS -Android

    By Takayuki IMAI

    Spatula

    Spatula

    iOS -Android

    By Kushal Dave

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/support.html b/support.html index e32beb20faf..7819106aa7b 100644 --- a/support.html +++ b/support.html @@ -1,4 +1,4 @@ -Support – React Native | A framework for building native apps using React

    Need help?

    React Native is worked on full-time by Facebook's product infrastructure user interface engineering teams. They're often around and available for questions.

    Community translation #

    The following is a list of translated docs offered by community volunteers. Send a pull request to fill the list!

    Stack Overflow #

    Many members of the community use Stack Overflow to ask questions. Read through the existing questions tagged with react-native or ask your own!

    Chat #

    Join us in #react-native on Reactiflux.

    Product Pains #

    React Native uses Product Pains for feature requests. It has a voting system to surface which issues are most important to the community. GitHub issues should only be used for bugs.

    Twitter #

    #reactnative hash tag on Twitter is used to keep up with the latest React Native news.

    © 2016 Facebook Inc.

    Need help?

    React Native is worked on full-time by Facebook's product infrastructure user interface engineering teams. They're often around and available for questions.

    Community translation #

    The following is a list of translated docs offered by community volunteers. Send a pull request to fill the list!

    Stack Overflow #

    Many members of the community use Stack Overflow to ask questions. Read through the existing questions tagged with react-native or ask your own!

    Chat #

    Join us in #react-native on Reactiflux.

    Product Pains #

    React Native uses Product Pains for feature requests. It has a voting system to surface which issues are most important to the community. GitHub issues should only be used for bugs.

    Twitter #

    #reactnative hash tag on Twitter is used to keep up with the latest React Native news.

    © 2016 Facebook Inc.
    \ No newline at end of file diff --git a/versions.html b/versions.html index f4508105f98..dfb06374a42 100644 --- a/versions.html +++ b/versions.html @@ -1,4 +1,4 @@ -Documentation archive – React Native | A framework for building native apps using React

    React Native Versions

    React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

    masterDocs
    0.26-rcDocsRelease Notes
    (current) 0.25DocsRelease Notes
    0.24DocsRelease Notes
    0.23DocsRelease Notes
    0.22DocsRelease Notes
    0.21DocsRelease Notes
    0.20DocsRelease Notes
    0.19DocsRelease Notes
    0.18DocsRelease Notes
    © 2016 Facebook Inc.

    React Native Versions

    React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

    masterDocs
    0.26-rcDocsRelease Notes
    (current) 0.25DocsRelease Notes
    0.24DocsRelease Notes
    0.23DocsRelease Notes
    0.22DocsRelease Notes
    0.21DocsRelease Notes
    0.20DocsRelease Notes
    0.19DocsRelease Notes
    0.18DocsRelease Notes
    © 2016 Facebook Inc.
    \ No newline at end of file