diff --git a/css/react-native.css b/css/react-native.css index 1331e880f53..83cf44113d9 100644 --- a/css/react-native.css +++ b/css/react-native.css @@ -1118,18 +1118,6 @@ div[data-twttr-id] iframe { margin-left: 26px; } -.edit-github { - font-size: 15px; - font-weight: normal; - float: right; -} - -.run-example { - font-size: 15px; - float: right; - margin-right: 20px; -} - #content { display: none; } diff --git a/docs/accessibility.html b/docs/accessibility.html index 028a20e0784..8182b073190 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,4 +1,4 @@ -Accessibility – React Native | A framework for building native apps using React

AccessibilityEdit 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}> diff --git a/docs/actionsheetios.html b/docs/actionsheetios.html index a2745afda19..93c7108bd47 100644 --- a/docs/actionsheetios.html +++ b/docs/actionsheetios.html @@ -1,4 +1,4 @@ -ActionSheetIOS – React Native | A framework for building native apps using React

ActionSheetIOS

Methods #

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

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

Edit on GitHubExamples #

'use strict'; +ActionSheetIOS – React Native | A framework for building native apps using React

ActionSheetIOS #

Edit on GitHub

Methods #

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

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

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/activityindicatorios.html b/docs/activityindicatorios.html index 397deea8635..b17799c092f 100644 --- a/docs/activityindicatorios.html +++ b/docs/activityindicatorios.html @@ -1,4 +1,4 @@ -ActivityIndicatorIOS – React Native | A framework for building native apps using React

ActivityIndicatorIOS

Edit on GitHubProps #

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.

Edit on GitHubExamples #

'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 { diff --git a/docs/alert.html b/docs/alert.html index e627c81a1cc..44bf1411a8b 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

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,7 +13,7 @@ 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) #

Edit on GitHubExamples #

'use strict'; +)

Methods #

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

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/alertios.html b/docs/alertios.html index dccf4fa9b9b..9db0047d58f 100644 --- a/docs/alertios.html +++ b/docs/alertios.html @@ -1,4 +1,4 @@ -AlertIOS – React Native | A framework for building native apps using React

AlertIOS

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 @@ -29,7 +29,7 @@ a text key, as well as optional onPress and styl text => console.log("Your username is "+text), null, 'default' -)

Edit on GitHubRun this exampleExamples #

'use strict'; +)

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/android-building-from-source.html b/docs/android-building-from-source.html index be5bf38a725..c633efbebd0 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 sourceEdit 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 & extraction instructions here)

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 & extraction instructions here)

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

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 { diff --git a/docs/android-setup.html b/docs/android-setup.html index 012b4b55e50..30202c4b400 100644 --- a/docs/android-setup.html +++ b/docs/android-setup.html @@ -1,4 +1,4 @@ -Android Setup – React Native | A framework for building native apps using React

Android SetupEdit 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. We don't discuss developer tool configuration such as IDEs here.

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

Edit on GitHubExamples #

'use strict'; + }}

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/animations.html b/docs/animations.html index 7da354943a3..ee32aa637ba 100644 --- a/docs/animations.html +++ b/docs/animations.html @@ -1,4 +1,4 @@ -Animations – React Native | A framework for building native apps using React

AnimationsEdit 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 diff --git a/docs/appregistry.html b/docs/appregistry.html index 9c3a2098120..ccc08621a52 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

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 diff --git a/docs/appstate.html b/docs/appstate.html index 1f908d73888..26584dd56e9 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

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 @@ -26,7 +26,7 @@ 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 #

Edit on GitHubExamples #

'use strict'; +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'; var React = require('react-native'); var { diff --git a/docs/appstateios.html b/docs/appstateios.html index bf3e8697030..a78d74b11cb 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

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 transition state that currently never happens for @@ -29,7 +29,7 @@ state will happen only momentarily.

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

Edit on GitHubExamples #

'use strict'; +// Initialize to 'active' instead of null.

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html index 17aceb178ce..5f8da498c78 100644 --- a/docs/asyncstorage.html +++ b/docs/asyncstorage.html @@ -1,4 +1,4 @@ -AsyncStorage – React Native | A framework for building native apps using React

AsyncStorage

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 @@ -11,7 +11,7 @@ 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.

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 matches the input format of multiSet. Returns a Promise object.

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

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);

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

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

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

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

Not supported by all native implementations.

Properties #

Edit on GitHubExamples #

'use strict'; +json. Returns a Promise object.

Not supported by all native implementations.

Properties #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/backandroid.html b/docs/backandroid.html index e9705fcebae..3fe5c772058 100644 --- a/docs/backandroid.html +++ b/docs/backandroid.html @@ -1,4 +1,4 @@ -BackAndroid – React Native | A framework for building native apps using React

BackAndroid

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(); diff --git a/docs/cameraroll.html b/docs/cameraroll.html index fb159a5a89e..e87d8ea0a14 100644 --- a/docs/cameraroll.html +++ b/docs/cameraroll.html @@ -1,6 +1,6 @@ -CameraRoll – React Native | A framework for building native apps using React

CameraRoll

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:

Edit on GitHubProps #

dataSource ListViewDataSource #

initialListSize number #

How many rows to render on initial component mount. Use this to make +rendering rows.

Props #

dataSource ListViewDataSource #

initialListSize number #

How many rows to render on initial component mount. Use this to make it so that the first screen worth of data appears at one time instead of over the course of multiple frames.

onChangeVisibleRows function #

(visibleRows, changedRows) => void

Called when the set of visible rows changes. visibleRows maps { sectionID: { rowID: true }} for all the visible rows, and @@ -60,7 +60,7 @@ pixels.

Edit on GitHubExamples #

'use strict'; +with horizontal={true}.

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/mapview.html b/docs/mapview.html index dce58df69f7..aecda69022d 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 GitHubProps #

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 @@ -29,7 +29,7 @@ Note that this has no effect unless showsUserLocation is enabled. Default value is true.

ioslegalLabelInsets {top: number, left: number, bottom: number, right: number} #

Insets for the map's legal label, originally at bottom left of the map. See EdgeInsetsPropType.js for more information.

iosmapType enum('standard', 'satellite', 'hybrid') #

The map type to be displayed.

  • standard: standard road map (default)
  • satellite: satellite view
  • hybrid: satellite view with roads and points of interest overlaid

iosmaxDelta number #

Maximum size of area that can be displayed.

iosminDelta number #

Minimum size of area that can be displayed.

iosoverlays [{coordinates: [{latitude: number, longitude: number}], lineWidth: number, strokeColor: [object Object], fillColor: [object Object], id: string}] #

Map overlays

iosshowsCompass bool #

If false compass won't be displayed on the map. Default value is true.

iosshowsPointsOfInterest bool #

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

Edit on GitHubExamples #

'use strict'; +Default value is true.

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/modal.html b/docs/modal.html index 1c48f9f27c9..775107fe6dd 100644 --- a/docs/modal.html +++ b/docs/modal.html @@ -1,10 +1,10 @@ -Modal – React Native | A framework for building native apps using React

Modal

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

This component is only available in iOS at this time.

Edit on GitHubProps #

animated bool #

onDismiss function #

transparent bool #

visible bool #

Edit on GitHubExamples #

'use strict'; +configureScene property.

This component is only available in iOS at this time.

Props #

animated bool #

onDismiss function #

transparent bool #

visible bool #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { diff --git a/docs/native-components-android.html b/docs/native-components-android.html index 82b689e9a48..28959cb9230 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 ComponentsEdit 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> { diff --git a/docs/native-components-ios.html b/docs/native-components-ios.html index 986424e19ec..044ce973ad2 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 ComponentsEdit 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" diff --git a/docs/native-modules-android.html b/docs/native-modules-android.html index 2b05cba4139..d7e83e11f75 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 ModulesEdit 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; diff --git a/docs/native-modules-ios.html b/docs/native-modules-ios.html index 2f585546a97..857488cd34f 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 ModulesEdit 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> diff --git a/docs/nativemethodsmixin.html b/docs/nativemethodsmixin.html index ec35eac9c1a..05f8c04cde0 100644 --- a/docs/nativemethodsmixin.html +++ b/docs/nativemethodsmixin.html @@ -1,4 +1,4 @@ -NativeMethodsMixin – React Native | A framework for building native apps using React

NativeMethodsMixin

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 diff --git a/docs/navigator-comparison.html b/docs/navigator-comparison.html index c4855199d8a..746c359977e 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 ComparisonEdit 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 diff --git a/docs/navigator.html b/docs/navigator.html index a697d24498a..4a64c60c050 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

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 @@ -28,7 +28,7 @@ on it to trigger navigation:

  • getCurrentRoutes() - return 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

Edit on GitHubProps #

configureScene function #

Optional function that allows configuration about scene animations and + other scene

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

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 diff --git a/docs/navigatorios.html b/docs/navigatorios.html index e95d3ada9e0..f23afc9eecb 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

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 @@ -38,10 +38,10 @@ transitions back to it

  • resetTo(route) - Replaces the top it });
  • Props passed to the NavigatorIOS component will set the default configuration for the navigation bar. Props passed as properties to a route object will set the configuration for that route's navigation bar, overriding any props -passed to the NavigatorIOS component.

    Edit on GitHubProps #

    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, +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

    Edit on GitHubExamples #

    '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

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var ViewExample = require('./ViewExample'); diff --git a/docs/netinfo.html b/docs/netinfo.html index 68bd4dec53e..22f2854ddce 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

    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) { @@ -31,7 +31,7 @@ internet connectivity.

    NetInfo.isConnected.addEventListener( 'change', handleFirstConnectivityChange -);

    Methods #

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

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

    static fetch() #

    static isConnectionExpensive(callback: (metered: ?boolean, error?: string) => void) #

    Properties #

    isConnected: ObjectExpression #

    Edit on GitHubExamples #

    'use strict'; +);

    Methods #

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

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

    static fetch() #

    static isConnectionExpensive(callback: (metered: ?boolean, error?: string) => void) #

    Properties #

    isConnected: ObjectExpression #

    Examples #

    Edit on GitHub
    'use strict'; const React = require('react-native'); const { diff --git a/docs/network.html b/docs/network.html index 70c57b24b6c..6f5773341e1 100644 --- a/docs/network.html +++ b/docs/network.html @@ -1,4 +1,4 @@ -Network – React Native | A framework for building native apps using React

    NetworkEdit 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', diff --git a/docs/panresponder.html b/docs/panresponder.html index 685b5d702b2..4df6836901d 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

    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. @@ -57,7 +57,7 @@ as well.

    Be careful with onStartShould* callbacks. They only reflect updat Once the node is the responder, you can rely on every start/end event being processed by the gesture and gestureState being updated accordingly. (numberActiveTouches) may not be totally accurate unless you -are the responder.

    Edit on GitHubExamples #

    'use strict'; +are the responder.

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/performance.html b/docs/performance.html index 40a471174ef..b46b141b706 100644 --- a/docs/performance.html +++ b/docs/performance.html @@ -1,4 +1,4 @@ -Performance – React Native | A framework for building native apps using React

    PerformanceEdit 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 diff --git a/docs/picker.html b/docs/picker.html index 67bd423c5db..49530aaa64e 100644 --- a/docs/picker.html +++ b/docs/picker.html @@ -1,9 +1,9 @@ -Picker – React Native | A framework for building native apps using React

    Picker

    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" /> <Picker.Item label="JavaScript" value="js" /> -</Picker>

    Edit on GitHubProps #

    onValueChange function #

    Callback for when an item is selected. This is called with the following parameters: +</Picker>

    Props #

    onValueChange function #

    Callback for when an item is selected. This is called with the following parameters: - itemValue: the value prop of the item that was selected - itemPosition: the index of the selected item in this picker

    selectedValue any #

    Value matching value of one of the items. Can be a string or an integer.

    style pickerStyleType #

    testID string #

    Used to locate this view in end-to-end tests.

    androidenabled bool #

    If set to false, the picker will be disabled, i.e. the user will not be able to make a selection.

    androidmode enum('dialog', 'dropdown') #

    On Android, specifies how to display the selection items when the user taps on the picker:

    • 'dialog': Show a modal dialog. This is the default.
    • 'dropdown': Shows a dropdown anchored to the picker view

    androidprompt string #

    Prompt string for this picker, used on Android in dialog mode as the title of the dialog.

    iositemStyle itemStylePropType #

    Style to apply to each of the item labels.

    © 2015 Facebook Inc.

    PickerIOS

    Edit on GitHubProps #

    itemStyle itemStylePropType #

    onValueChange function #

    selectedValue any #

    Edit on GitHubExamples #

    '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 { diff --git a/docs/pixelratio.html b/docs/pixelratio.html index a63ec377c5f..ebc53825014 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

    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), @@ -11,7 +11,7 @@ Settings > Display > Font size, on iOS it will always return the default p @platform android

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

    Edit on GitHubDescription #

    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.

    © 2015 Facebook Inc.

    Platform Specific CodeEdit 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 diff --git a/docs/progressbarandroid.html b/docs/progressbarandroid.html index 5e1bea90b24..42c7b783725 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

    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}> @@ -12,8 +12,8 @@ that the app is loading or there is some activity in the app.

    Example:

    style={styles.loadingComponent} /> ); -},

    Edit on GitHubProps #

    color color #

    Color of the progress bar.

    indeterminate indeterminateType #

    If the progress bar will show indeterminate progress. Note that this -can only be false if styleAttr is Horizontal.

    progress number #

    The progress value (between 0 and 1).

    styleAttr STYLE_ATTRIBUTES #

    Style of the ProgressBar. One of:

    • Horizontal
    • Normal (default)
    • Small
    • Large
    • Inverse
    • SmallInverse
    • LargeInverse

    testID string #

    Used to locate this view in end-to-end tests.

    Edit on GitHubExamples #

    'use strict'; +},

    Props #

    color color #

    Color of the progress bar.

    indeterminate indeterminateType #

    If the progress bar will show indeterminate progress. Note that this +can only be false if styleAttr is Horizontal.

    progress number #

    The progress value (between 0 and 1).

    styleAttr STYLE_ATTRIBUTES #

    Style of the ProgressBar. One of:

    • Horizontal
    • Normal (default)
    • Small
    • Large
    • Inverse
    • SmallInverse
    • LargeInverse

    testID string #

    Used to locate this view in end-to-end tests.

    Examples #

    Edit on GitHub
    'use strict'; var ProgressBar = require('ProgressBarAndroid'); var React = require('React'); diff --git a/docs/progressviewios.html b/docs/progressviewios.html index 80acf60a064..76b1fbc87e7 100644 --- a/docs/progressviewios.html +++ b/docs/progressviewios.html @@ -1,4 +1,4 @@ -ProgressViewIOS – React Native | A framework for building native apps using React

    ProgressViewIOS

    Use ProgressViewIOS to render a UIProgressView on iOS.

    Edit on GitHubProps #

    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.

    Edit on GitHubExamples #

    '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 { diff --git a/docs/pulltorefreshviewandroid.html b/docs/pulltorefreshviewandroid.html index 0c468b4be89..413b7dff8ba 100644 --- a/docs/pulltorefreshviewandroid.html +++ b/docs/pulltorefreshviewandroid.html @@ -1,6 +1,6 @@ -PullToRefreshViewAndroid – React Native | A framework for building native apps using React

    PullToRefreshViewAndroid

    React view that supports a single scrollable child view (e.g. ScrollView). When this child +PullToRefreshViewAndroid – React Native | A framework for building native apps using React

    PullToRefreshViewAndroid #

    Edit on GitHub

    React view that supports a single scrollable child view (e.g. ScrollView). When this child view is at scrollY: 0, swiping down triggers an onRefresh event.

    The style {flex: 1} might be required to ensure the expected behavior of the child component -(e.g. when the child is expected to scroll with ScrollView or ListView).

    Edit on GitHubProps #

    colors [[object Object]] #

    The colors (at least one) that will be used to draw the refresh indicator

    enabled bool #

    Whether the pull to refresh functionality is enabled

    progressBackgroundColor color #

    The background color of the refresh indicator

    refreshing bool #

    Whether the view should be indicating an active refresh

    size RefreshLayoutConsts.SIZE.DEFAULT #

    Size of the refresh indicator, see PullToRefreshViewAndroid.SIZE

    Edit on GitHubExamples #

    'use strict'; +(e.g. when the child is expected to scroll with ScrollView or ListView).

    Props #

    colors [[object Object]] #

    The colors (at least one) that will be used to draw the refresh indicator

    enabled bool #

    Whether the pull to refresh functionality is enabled

    progressBackgroundColor color #

    The background color of the refresh indicator

    refreshing bool #

    Whether the view should be indicating an active refresh

    size RefreshLayoutConsts.SIZE.DEFAULT #

    Size of the refresh indicator, see PullToRefreshViewAndroid.SIZE

    Examples #

    Edit on GitHub
    'use strict'; const React = require('react-native'); const { diff --git a/docs/pushnotificationios.html b/docs/pushnotificationios.html index da70081c2cf..bff84f83427 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

    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:

    // Required to register for notifications @@ -36,7 +36,7 @@ memory leaks

    constructor(nativeNotif: Object) #

    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

    Edit on GitHubExamples #

    'use strict'; +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 { diff --git a/docs/refreshcontrol.html b/docs/refreshcontrol.html index 3670a4b0540..c47628d6e28 100644 --- a/docs/refreshcontrol.html +++ b/docs/refreshcontrol.html @@ -1,6 +1,6 @@ -RefreshControl – React Native | A framework for building native apps using React

    RefreshControl

    This component is used inside a ScrollView 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 to add pull to refresh functionality. When the ScrollView is at scrollY: 0, swiping down -triggers an onRefresh event.

    Edit on GitHubProps #

    onRefresh function #

    Called when the view starts refreshing.

    refreshing bool #

    Whether the view should be indicating an active refresh.

    androidcolors [[object Object]] #

    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.

    Edit on GitHubExamples #

    'use strict'; +triggers an onRefresh event.

    Props #

    onRefresh function #

    Called when the view starts refreshing.

    refreshing bool #

    Whether the view should be indicating an active refresh.

    androidcolors [[object Object]] #

    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'; const React = require('react-native'); const { diff --git a/docs/running-on-device-android.html b/docs/running-on-device-android.html index b4261d7425a..9fffa0a2eb4 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 DeviceEdit 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.
    © 2015 Facebook Inc.

    Running On DeviceEdit 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.

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

    © 2015 Facebook Inc.

    ScrollView

    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 @@ -6,7 +6,7 @@ set the height of the view directly (discouraged) or make sure all parent views have bounded height. Forgetting to transfer {flex: 1} down the view stack can lead to errors here, which the element inspector makes easy to debug.

    Doesn't yet support other contained responders from blocking this scroll -view from becoming the responder.

    Edit on GitHubProps #

    contentContainerStyle StyleSheetPropType(ViewStylePropTypes) #

    These styles will be applied to the scroll view content container which +view from becoming the responder.

    Props #

    contentContainerStyle StyleSheetPropType(ViewStylePropTypes) #

    These styles will be applied to the scroll view content container which wraps all of the child views. Example:

    return ( <ScrollView contentContainerStyle={styles.contentContainer}> </ScrollView> @@ -86,7 +86,7 @@ with snapToAlignment.

    ioszoomScale number #

    The current scale of the scroll view content. The default value is 1.0.

    Edit on GitHubExamples #

    'use strict'; +with horizontal={true}.

    ioszoomScale number #

    The current scale of the scroll view content. The default value is 1.0.

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/segmentedcontrolios.html b/docs/segmentedcontrolios.html index fa53531dc3e..cf1c8d6cdf7 100644 --- a/docs/segmentedcontrolios.html +++ b/docs/segmentedcontrolios.html @@ -1,8 +1,8 @@ -SegmentedControlIOS – React Native | A framework for building native apps using React

    SegmentedControlIOS

    Use SegmentedControlIOS to render a UISegmentedControl iOS.

    Edit on GitHubProps #

    enabled bool #

    If false the user won't be able to interact with the control. +SegmentedControlIOS – React Native | A framework for building native apps using React

    SegmentedControlIOS #

    Edit on GitHub

    Use SegmentedControlIOS to render a UISegmentedControl iOS.

    Props #

    enabled bool #

    If false the user won't be able to interact with the control. Default value is true.

    momentary bool #

    If true, then selecting a segment won't persist visually. The onValueChange callback will still work as expected.

    onChange function #

    Callback that is called when the user taps a segment; passes the event as an argument

    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.

    Edit on GitHubExamples #

    'use strict'; +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 { diff --git a/docs/signed-apk-android.html b/docs/signed-apk-android.html index 0da8c52d212..819e08f4188 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 APKEdit 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

    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 (loosing 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,

    ... diff --git a/docs/sliderios.html b/docs/sliderios.html index f6adf48eab1..39f5069c9c9 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 GitHubProps #

    disabled bool #

    If true the user won't be able to move the slider. +SliderIOS – React Native | A framework for building native apps using React

    SliderIOS #

    Edit on GitHub

    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 default blue gradient image.

    maximumValue number #

    Initial maximum value of the slider. Default value is 1.

    minimumTrackImage Image.propTypes.source #

    Assigns a minimum track image. Only static images are supported. The @@ -11,7 +11,7 @@ Default value is 0.

    value number #

    Initial value of the slider. The value should be between minimumValue 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.

    Edit on GitHubExamples #

    'use strict'; +the value, the component won't be reset to its initial value.

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/statusbarios.html b/docs/statusbarios.html index d58aad9c3b9..feb495b9992 100644 --- a/docs/statusbarios.html +++ b/docs/statusbarios.html @@ -1,4 +1,4 @@ -StatusBarIOS – React Native | A framework for building native apps using React

    StatusBarIOS

    Methods #

    static setStyle(style: StatusBarStyle, animated?: boolean) #

    static setHidden(hidden: boolean, animation?: StatusBarAnimation) #

    static setNetworkActivityIndicatorVisible(visible: boolean) #

    Edit on GitHubExamples #

    'use strict'; +StatusBarIOS – React Native | A framework for building native apps using React

    StatusBarIOS #

    Edit on GitHub

    Methods #

    static setStyle(style: StatusBarStyle, animated?: boolean) #

    static setHidden(hidden: boolean, animation?: StatusBarAnimation) #

    static setNetworkActivityIndicatorVisible(visible: boolean) #

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/style.html b/docs/style.html index 0d569e392e5..72277ed832c 100644 --- a/docs/style.html +++ b/docs/style.html @@ -1,4 +1,4 @@ -Style – React Native | A framework for building native apps using React

    StyleEdit 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: { diff --git a/docs/stylesheet.html b/docs/stylesheet.html index da719fdba43..844d37580f3 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

    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, diff --git a/docs/switch.html b/docs/switch.html index d2a0e107eda..3d4ff968932 100644 --- a/docs/switch.html +++ b/docs/switch.html @@ -1,6 +1,6 @@ -Switch – React Native | A framework for building native apps using React

    Switch

    Universal two-state toggle component.

    Edit on GitHubProps #

    disabled bool #

    If true the user won't be able to toggle the switch. +Switch – React Native | A framework for building native apps using React

    Switch #

    Edit on GitHub

    Universal two-state toggle component.

    Props #

    disabled bool #

    If true the user won't be able to toggle the switch. 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.

    Edit on GitHubExamples #

    'use strict'; +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 { diff --git a/docs/tabbarios-item.html b/docs/tabbarios-item.html index d423bde17fe..231e785c77e 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 GitHubProps #

    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 diff --git a/docs/tabbarios.html b/docs/tabbarios.html index d8c05aa7f1a..992f57a39dd 100644 --- a/docs/tabbarios.html +++ b/docs/tabbarios.html @@ -1,4 +1,4 @@ -TabBarIOS – React Native | A framework for building native apps using React

    TabBarIOS

    Edit on GitHubProps #

    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

    Edit on GitHubExamples #

    '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 { diff --git a/docs/testing.html b/docs/testing.html index 39e79fc66ba..7043ef01469 100644 --- a/docs/testing.html +++ b/docs/testing.html @@ -1,4 +1,4 @@ -Testing – React Native | A framework for building native apps using React

    TestingEdit 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" diff --git a/docs/text.html b/docs/text.html index 09dca00db12..9f72053388e 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

    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 @@ -23,12 +23,12 @@ each other on account of the literal newlines:

    : 20, fontWeight: 'bold', }, -};

    Edit on GitHubProps #

    accessible #

    numberOfLines number #

    Used to truncate the text with an ellipsis after computing the text +};

    Props #

    accessible #

    numberOfLines number #

    Used to truncate the text with an ellipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number.

    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 -default, a gray oval highlights the text on press down.

    Edit on GitHubDescription #

    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'}}> +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'}}> and red diff --git a/docs/textinput.html b/docs/textinput.html index b8500544c3a..e2f4c8c18c6 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

    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 @@ -8,7 +8,7 @@ example:

    <TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}} onChangeText={(text) => this.setState({text})} value={this.state.text} - />

    Note that some props are only available with multiline={true/false}:

    Edit on GitHubProps #

    autoCapitalize enum('none', 'sentences', 'words', 'characters') #

    Can tell TextInput to automatically capitalize certain characters.

    • characters: all characters,
    • words: first letter of each word
    • sentences: first letter of each sentence (default)
    • none: don't auto capitalize anything

    autoCorrect bool #

    If false, disables auto-correct. The default value is true.

    autoFocus bool #

    If true, focuses the input on componentDidMount. + />

    Note that some props are only available with multiline={true/false}:

    Props #

    autoCapitalize enum('none', 'sentences', 'words', 'characters') #

    Can tell TextInput to automatically capitalize certain characters.

    • characters: all characters,
    • words: first letter of each word
    • sentences: first letter of each sentence (default)
    • none: don't auto capitalize anything

    autoCorrect bool #

    If false, disables auto-correct. The default value is true.

    autoFocus bool #

    If true, focuses the input on componentDidMount. The default value is false.

    defaultValue string #

    Provides an initial value that will change when the user starts typing. Useful for simple use-cases where you don't want to deal with listening to events and updating the value prop to keep the controlled state in sync.

    editable bool #

    If false, text is not editable. The default value is true.

    keyboardType enum('default', 'email-address', 'numeric', 'phone-pad', 'ascii-capable', 'numbers-and-punctuation', 'url', 'number-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search') #

    Determines which keyboard to open, e.g.numeric.

    The following values work across platforms: diff --git a/docs/timers.html b/docs/timers.html index 47791f38045..9a2572478a1 100644 --- a/docs/timers.html +++ b/docs/timers.html @@ -1,4 +1,4 @@ -Timers – React Native | A framework for building native apps using React

    TimersEdit 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) diff --git a/docs/toastandroid.html b/docs/toastandroid.html index 28e3bdaa7ac..517cb465988 100644 --- a/docs/toastandroid.html +++ b/docs/toastandroid.html @@ -1,5 +1,5 @@ -ToastAndroid – React Native | A framework for building native apps using React

    ToastAndroid

    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 #

    Edit on GitHubExamples #

    '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: string, duration: number) #

    Properties #

    SHORT: MemberExpression #

    LONG: MemberExpression #

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/toolbarandroid.html b/docs/toolbarandroid.html index 3652669e670..40f6f8daf28 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

    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 @@ -18,7 +18,7 @@ onActionSelected: if (position === 0) { // index of 'Settings' showSettings(); } -}

    Edit on GitHubProps #

    actions [{title: string, icon: optionalImageSource, show: enum('always', 'ifRoom', 'never'), showWithText: bool}] #

    Sets possible actions on the toolbar as part of the action menu. These are displayed as icons +}

    Props #

    actions [{title: string, icon: optionalImageSource, show: enum('always', 'ifRoom', 'never'), showWithText: bool}] #

    Sets possible actions on the toolbar as part of the action menu. These are displayed as icons or text on the right side of the widget. If they don't fit they are placed in an 'overflow' menu.

    This property takes an array of objects, where each object has the following keys:

    • title: required, the title of this action
    • icon: the icon for this action, e.g. require('./some_icon.png')
    • show: when to show this action as an icon or hide it in the overflow menu: always, ifRoom or never
    • showWithText: boolean, whether to show text alongside the icon or not

    contentInsetEnd number #

    Sets the content inset for the toolbar ending edge.

    The content inset affects the valid area for Toolbar content other than @@ -31,7 +31,7 @@ along well-known gridlines.

    onIconClicked function #

    Callback called when the icon is selected.

    overflowIcon optionalImageSource #

    Sets the overflow icon.

    rtl bool #

    Used to set the toolbar direction to RTL. In addition to this property you need to add

    android:supportsRtl="true"

    to your application AndroidManifest.xml and then call 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.

    Edit on GitHubExamples #

    'use strict'; +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 { diff --git a/docs/touchablehighlight.html b/docs/touchablehighlight.html index e0ec6ee2ddb..9d91d9f680b 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

    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 @@ -12,7 +12,7 @@ backgroundColor of the wrapped view isn't explicitly set to an opaque color /> </TouchableHighlight> ); -},

    NOTE: TouchableHighlight supports only one child

    If you wish to have several child components, wrap them in a View.

    Edit on GitHubProps #

    activeOpacity number #

    Determines what the opacity of the wrapped view should be when touch is +},

    NOTE: TouchableHighlight supports only one child

    If you wish to have several child components, wrap them in a View.

    Props #

    activeOpacity number #

    Determines what the opacity of the wrapped view should be when touch is active.

    onHideUnderlay function #

    Called immediately after the underlay is hidden

    onShowUnderlay function #

    Called immediately after the underlay is shown

    underlayColor color #

    The color of the underlay that will show through when the touch is active.

    © 2015 Facebook Inc.

    TouchableNativeFeedback

    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 @@ -13,7 +13,7 @@ of RCTView node with some additional properties set.

    Background drawable o </View> </TouchableNativeFeedback> ); -},

    Edit on GitHubProps #

    background backgroundPropType #

    Determines the type of background drawable that's going to be used to +},

    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 diff --git a/docs/touchableopacity.html b/docs/touchableopacity.html index 2785cbb8cad..e6448faf865 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

    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() { @@ -10,7 +10,7 @@ easy to add to an app without weird side-effects.

    Example:

    /> </TouchableOpacity> ); -},

    Edit on GitHubProps #

    activeOpacity number #

    Determines what the opacity of the wrapped view should be when touch is +},

    Props #

    activeOpacity number #

    Determines what the opacity of the wrapped view should be when touch is active.

    © 2015 Facebook Inc.

    TouchableWithoutFeedback

    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.

    Edit on GitHubProps #

    accessibilityComponentType View.AccessibilityComponentType #

    accessibilityTraits View.AccessibilityTraits, [View.AccessibilityTraits] #

    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.

    onLayout function #

    Invoked on mount and layout changes with

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

    onLongPress function #

    onPress function #

    Called when the touch is released, but not if cancelled (e.g. by a scroll +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, [View.AccessibilityTraits] #

    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.

    onLayout function #

    Invoked on mount and layout changes with

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

    onLongPress function #

    onPress function #

    Called when the touch is released, but not if cancelled (e.g. by a scroll that steals the responder lock).

    onPressIn function #

    onPressOut function #

    pressRetentionOffset {top: number, left: number, bottom: number, right: number} #

    When the scroll view is disabled, this defines how far your touch may move off of the button, before deactivating the button. Once deactivated, try moving it back and you'll see that the button is once again diff --git a/docs/transforms.html b/docs/transforms.html index a09601e1751..e1b83044c5c 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 GitHubProps #

    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 #

    © 2015 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 #

    © 2015 Facebook Inc.

    TroubleshootingEdit 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"

    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 diff --git a/docs/tutorial.html b/docs/tutorial.html index 22dfacaf67e..97d3c36d45d 100644 --- a/docs/tutorial.html +++ b/docs/tutorial.html @@ -1,4 +1,4 @@ -Tutorial – React Native | A framework for building native apps using React

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

    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.

    Development #

    For iOS, you can now 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.

    For Android, run react-native run-android from AwesomeProject to install the generated app on your emulator or device, and 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.

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

    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.

    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.

    Development #

    For iOS, you can now 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.

    For Android, run react-native run-android from AwesomeProject to install the generated app on your emulator or device, and 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.

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

    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, diff --git a/docs/upgrading.html b/docs/upgrading.html index fc7cae93989..407dbdcd819 100644 --- a/docs/upgrading.html +++ b/docs/upgrading.html @@ -1,4 +1,4 @@ -Upgrading – React Native | A framework for building native apps using React

    UpgradingEdit 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 diff --git a/docs/vibrationios.html b/docs/vibrationios.html index 8677e0cd16d..75677fc89b2 100644 --- a/docs/vibrationios.html +++ b/docs/vibrationios.html @@ -1,7 +1,7 @@ -VibrationIOS – React Native | A framework for building native apps using React

    VibrationIOS

    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

    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() #

    Edit on GitHubExamples #

    'use strict'; +simulator.

    Vibration patterns are currently unsupported.

    Methods #

    static vibrate() #

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/videos.html b/docs/videos.html index 23ba2368f2c..8ae09d1f8a0 100644 --- a/docs/videos.html +++ b/docs/videos.html @@ -1,4 +1,4 @@ -Videos – React Native | A framework for building native apps using React

    VideosEdit on GitHub

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

    Videos #

    Edit on GitHub
    diff --git a/docs/view.html b/docs/view.html index 666f2b2862a..cd83e6b9382 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

    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 @@ -9,7 +9,7 @@ wraps two colored boxes and custom component in a row with padding.

    ={{backgroundColor: 'red', flex: 0.5}} /> <MyCustomComponent {...customProps} /> </View>

    Views are designed to be used with StyleSheets for clarity and -performance, although inline styles are also supported.

    Edit on GitHubProps #

    accessibilityLabel string #

    Overrides the text that's read by the screen reader when the user interacts +performance, although inline styles are also supported.

    Props #

    accessibilityLabel string #

    Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space.

    accessible bool #

    When true, indicates that the view is an accessibility element. By default, all the touchable elements are accessible.

    onAccessibilityTap function #

    When accessible is true, the system will try to invoke this function @@ -87,7 +87,7 @@ modify this component's dimensions nor its children; for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view and quickly composite it during each frame.

    Rasterization incurs an off-screen drawing pass and the bitmap consumes -memory. Test and measure when using this property.

    Edit on GitHubExamples #

    'use strict'; +memory. Test and measure when using this property.

    Examples #

    Edit on GitHub
    'use strict'; var Platform = require('Platform'); var React = require('react-native'); diff --git a/docs/viewpagerandroid.html b/docs/viewpagerandroid.html index cd62a7556ee..c34e73640d0 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

    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 @@ -25,7 +25,7 @@ child.

    Example:

    render: 'center', padding: 20, } -}

    Edit on GitHubProps #

    initialPage number #

    Index of initial page that should be selected. Use setPage method to +}

    Props #

    initialPage number #

    Index of initial page that should be selected. Use setPage method to update the page, and onPageSelected to monitor page changes

    keyboardDismissMode enum('none', 'on-drag') #

    Determines whether the keyboard gets dismissed in response to a drag. - 'none' (the default), drags do not dismiss the keyboard. - 'on-drag', the keyboard is dismissed when a drag begins.

    onPageScroll function #

    Executed when transitioning between pages (ether because of animation for @@ -42,7 +42,7 @@ 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

    Edit on GitHubExamples #

    'use strict'; + - position - index of page that has been selected

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var { diff --git a/docs/webview.html b/docs/webview.html index a9ec945d01b..63f63d3e3d3 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

    Renders a native WebView.

    Edit on GitHubProps #

    automaticallyAdjustContentInsets bool #

    contentInset {top: number, left: number, bottom: number, right: number} #

    html string #

    injectedJavaScript string #

    Sets the JS to be injected when the webpage loads.

    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.

    startInLoadingState bool #

    url string #

    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 +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 #

    injectedJavaScript string #

    Sets the JS to be injected when the webpage loads.

    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.

    startInLoadingState bool #

    url string #

    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 NOTE : "In order for video to play inline, not only does this @@ -10,7 +10,7 @@ for UIScrollViewDecelerationRateNormal and UIScrollViewDecelerationRateFast respectively. - Normal: 0.998 - Fast: 0.9 (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.

    iosscalesPageToFit bool #

    Sets whether the webpage scales to fit the view and the user can change the scale.

    iosscrollEnabled bool #

    Edit on GitHubExamples #

    'use strict'; +or false from this method to continue loading the request.

    iosscalesPageToFit bool #

    Sets whether the webpage scales to fit the view and the user can change the scale.

    iosscrollEnabled bool #

    Examples #

    Edit on GitHub
    'use strict'; var React = require('react-native'); var {