diff --git a/blog/2016/03/24/introducing-hot-reloading.html b/blog/2016/03/24/introducing-hot-reloading.html index 6575eef7e72..5fcea3e18e9 100644 --- a/blog/2016/03/24/introducing-hot-reloading.html +++ b/blog/2016/03/24/introducing-hot-reloading.html @@ -1,4 +1,4 @@ -Introducing Hot Reloading – React Native | A framework for building native apps using React

Introducing Hot Reloading

March 24, 2016 by Martín Bigio


React Native goal is to give you the best possible developer experience. A big part of it is the time it takes between you save a file and be able to see the changes. Our goal is to get this feedback loop to be under 1 second, even as your app grows.

We got close to this ideal via three main features:

  • Use JavaScript as the language doesn't have a long compilation cycle time.
  • Implement a tool called Packager that transforms es6/flow/jsx files into normal JavaScript that the VM can understand. It was designed as a server that keeps intermediate state in memory to enable fast incremental changes and uses multiple cores.
  • Build a feature called Live Reload that reloads the app on save.

At this point, the bottleneck for developers is no longer the time it takes to reload the app but losing the state of your app. A common scenario is to work on a feature that is multiple screens away from the launch screen. Every time you reload, you've got to click on the same path again and again to get back to your feature, making the cycle multiple-seconds long.

Hot Reloading #

The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI.

A video is worth a thousand words. Check out the difference between Live Reload (current) and Hot Reload (new).

+Introducing Hot Reloading – React Native | A framework for building native apps using React

Introducing Hot Reloading

March 24, 2016 by Martín Bigio


React Native goal is to give you the best possible developer experience. A big part of it is the time it takes between you save a file and be able to see the changes. Our goal is to get this feedback loop to be under 1 second, even as your app grows.

We got close to this ideal via three main features:

  • Use JavaScript as the language doesn't have a long compilation cycle time.
  • Implement a tool called Packager that transforms es6/flow/jsx files into normal JavaScript that the VM can understand. It was designed as a server that keeps intermediate state in memory to enable fast incremental changes and uses multiple cores.
  • Build a feature called Live Reload that reloads the app on save.

At this point, the bottleneck for developers is no longer the time it takes to reload the app but losing the state of your app. A common scenario is to work on a feature that is multiple screens away from the launch screen. Every time you reload, you've got to click on the same path again and again to get back to your feature, making the cycle multiple-seconds long.

Hot Reloading #

The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI.

A video is worth a thousand words. Check out the difference between Live Reload (current) and Hot Reload (new).

If you look closely, you can notice that it is possible to recover from a red box and you can also start importing modules that were not previously there without having to do a full reload.

Word of warning: because JavaScript is a very stateful language, hot reloading cannot be perfectly implemented. In practice, we found out that the current setup is working well for a large amount of usual use cases and a full reload is always available in case something gets messed up.

Hot reloading is available as of 0.22, you can enable it:

  • Open the developper menu
  • Tap on "Enable Hot Reloading"

Implementation in a nutshell #

Now that we've seen why we want it and how to use it, the fun part begins: how does it actually works.

Hot Reloading is built on top of a feature Hot Module Replacement, or HMR. It was first introduced by Webpack and we implemented it inside of React Native Packager. HMR makes the Packager watch for file changes and send HMR updates to a thin HMR runtime included on the app.

In a nutshell, the HMR update contains the new code of the JS modules that changed. When the runtime receives them, it replaces the old modules' code with the new one:

The HMR update contains a bit more than just the module's code we want to change because replacing it, it's not enough for the runtime to pick up the changes. The problem is that the module system may have already cached the exports of the module we want to update. For instance, say you have an app composed by these two modules:

// log.js function log(message) { @@ -85,6 +85,6 @@ export default function \ No newline at end of file diff --git a/blog/index.html b/blog/index.html index 704a993d4ac..7111c0838f3 100644 --- a/blog/index.html +++ b/blog/index.html @@ -1,4 +1,4 @@ -Blog – React Native | A framework for building native apps using React

Introducing Hot Reloading

March 24, 2016 by Martín Bigio


React Native goal is to give you the best possible developer experience. A big part of it is the time it takes between you save a file and be able to see the changes. Our goal is to get this feedback loop to be under 1 second, even as your app grows.

We got close to this ideal via three main features:

  • Use JavaScript as the language doesn't have a long compilation cycle time.
  • Implement a tool called Packager that transforms es6/flow/jsx files into normal JavaScript that the VM can understand. It was designed as a server that keeps intermediate state in memory to enable fast incremental changes and uses multiple cores.
  • Build a feature called Live Reload that reloads the app on save.

At this point, the bottleneck for developers is no longer the time it takes to reload the app but losing the state of your app. A common scenario is to work on a feature that is multiple screens away from the launch screen. Every time you reload, you've got to click on the same path again and again to get back to your feature, making the cycle multiple-seconds long.

Hot Reloading #

The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI.

A video is worth a thousand words. Check out the difference between Live Reload (current) and Hot Reload (new).

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

Introducing Hot Reloading

March 24, 2016 by Martín Bigio


React Native goal is to give you the best possible developer experience. A big part of it is the time it takes between you save a file and be able to see the changes. Our goal is to get this feedback loop to be under 1 second, even as your app grows.

We got close to this ideal via three main features:

  • Use JavaScript as the language doesn't have a long compilation cycle time.
  • Implement a tool called Packager that transforms es6/flow/jsx files into normal JavaScript that the VM can understand. It was designed as a server that keeps intermediate state in memory to enable fast incremental changes and uses multiple cores.
  • Build a feature called Live Reload that reloads the app on save.

At this point, the bottleneck for developers is no longer the time it takes to reload the app but losing the state of your app. A common scenario is to work on a feature that is multiple screens away from the launch screen. Every time you reload, you've got to click on the same path again and again to get back to your feature, making the cycle multiple-seconds long.

Hot Reloading #

The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI.

A video is worth a thousand words. Check out the difference between Live Reload (current) and Hot Reload (new).

If you look closely, you can notice that it is possible to recover from a red box and you can also start importing modules that were not previously there without having to do a full reload.

Word of warning: because JavaScript is a very stateful language, hot reloading cannot be perfectly implemented. In practice, we found out that the current setup is working well for a large amount of usual use cases and a full reload is always available in case something gets messed up.

Hot reloading is available as of 0.22, you can enable it:

  • Open the developper menu
  • Tap on "Enable Hot Reloading"

Implementation in a nutshell #

Now that we've seen why we want it and how to use it, the fun part begins: how does it actually works.

Hot Reloading is built on top of a feature Hot Module Replacement, or HMR. It was first introduced by Webpack and we implemented it inside of React Native Packager. HMR makes the Packager watch for file changes and send HMR updates to a thin HMR runtime included on the app.

In a nutshell, the HMR update contains the new code of the JS modules that changed. When the runtime receives them, it replaces the old modules' code with the new one:

The HMR update contains a bit more than just the module's code we want to change because replacing it, it's not enough for the runtime to pick up the changes. The problem is that the module system may have already cached the exports of the module we want to update. For instance, say you have an app composed by these two modules:

// log.js function log(message) { @@ -85,6 +85,6 @@ export default function \ No newline at end of file diff --git a/css/react-native.css b/css/react-native.css index 98e60504a1b..d61d0a695fb 100644 --- a/css/react-native.css +++ b/css/react-native.css @@ -262,7 +262,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li .nav-main .nav-site-external { float: right; - margin: 0; + margin: 0 12px 0 0; } .nav-main .nav-site li { @@ -299,6 +299,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li margin-left: 1px; width: 34px; } + .nav-main a.nav-home { color: white; } @@ -316,10 +317,65 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li font-size: 16px; font-weight: 800; color: #05A5D1; - margin-left: 5px; + margin-left: 8px; text-decoration: underline; } +@media screen and (max-width: 680px) { + .nav-main .nav-home { + font-size: 20px; + } + + .nav-main a.nav-version { + font-size: 14px; + } + + .nav-main .nav-site-wrapper { + display: block; + overflow: hidden; + } + + .nav-main ul { + display: -webkit-flex; + display: flex; + overflow: hidden; + } + + .nav-main li { + -webkit-flex: 1; + flex: 1; + } + + .nav-main .nav-site li a { + width: 100%; + padding: 0; + text-align: center; + font-size: 14px; + } + + .nav-main .nav-site a.active { + color: #05A5D1; + font-weight: bold; + background-color: transparent; + } + + .nav-main .nav-site-internal { + margin: 0; + width: 100%; + } + + .nav-main .nav-site-external { + position: absolute; + top: 0; + right: 0; + float: none; + } + + .nav-main .nav-site-external li a { + padding: 0 6px; + } +} + .hero { background: #05A5D1; padding: 50px 0; @@ -486,15 +542,6 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li box-shadow: 5px 5px 5px #888888; } -.versions ul { - list-style: none; -} - -.versions li { - font-size: 16px; - padding-top: 10px; -} - #examples h3, .home-presentation h3 { color: #2d2d2d; font-size: 24px; @@ -1199,6 +1246,18 @@ div[data-twttr-id] iframe { border-radius: 20px; } +.versions th { + text-align: right; +} + +.versions td, .versions th { + padding: 2px 5px; +} + +.versions tr:nth-child(2n+1) { + background-color: hsl(198, 100%, 94%); +} + @media only screen and (max-device-width: 1024px) { #content { @@ -1229,10 +1288,13 @@ div[data-twttr-id] iframe { margin: 0; } .nav-main .nav-site a { - padding: 0 4px; + padding: 0 8px; + } + .nav-main .nav-home { + margin-left: 8px; } .nav-main .wrap { - padding: 0 2px 0 4px; + padding: 0; } .home-divider { display: none; @@ -1255,7 +1317,7 @@ div[data-twttr-id] iframe { .nav-docs { float: none; width: auto; - margin-top: -20px; + margin-top: -8px; margin-bottom: 20px; } h1 { @@ -1283,6 +1345,11 @@ div.algolia-search-wrapper { margin-left: 15px; } +.algolia-autocomplete .aa-dropdown-menu { + margin-left: -210px; + margin-top: -4px; +} + @media screen and (max-width: 960px) { div.algolia-search-wrapper { display: none; @@ -1290,81 +1357,52 @@ div.algolia-search-wrapper { } input#algolia-doc-search { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-family: proxima-nova, "Helvetica Neue", Helvetica, Arial, sans-serif; - - background: transparent url('../img/search.png') no-repeat left center; + background: transparent url('../img/search.png') no-repeat 10px center; background-size: 16px 16px; - padding-left: 30px; + padding: 0 10px; + padding-left: 35px; + margin-top: 10px; + height: 30px; font-size: 16px; line-height: 20px; - background-color: #3B3738; - border-bottom: solid 3px #3B3738; + background-color: #555; + border-radius: 4px; color: white; outline: none; - width: 130px; - height: 53px; - - transition: border-color .2s ease, width .2s ease; - -webkit-transition: border-color .2s ease, width .2s ease; - -moz-transition: border-color .2s ease, width .2s ease; - -o-transition: border-color .2s ease, width .2s ease; + border: none; + width: 170px; } input#algolia-doc-search:focus { - border-color: #05A5D1; - width: 240px; -} - -@media screen and (max-width: 1085px) { - input#algolia-doc-search:focus { - width: 178px; - } + width: 220px; } .algolia-autocomplete { vertical-align: top; height: 53px; - - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-family: proxima-nova, "Helvetica Neue", Helvetica, Arial, sans-serif; } -/* Bottom border of each suggestion */ -.algolia-docsearch-suggestion { - border-bottom-color: #05A5D1; -} -/* Main category headers */ .algolia-docsearch-suggestion--category-header { background-color: #3B3738; } -/* Highlighted search terms */ .algolia-docsearch-suggestion--highlight { color: #05A5D1; } -/* Highligted search terms in the main category headers */ .algolia-docsearch-suggestion--category-header .algolia-docsearch-suggestion--highlight { background-color: #05A5D1; } -/* Currently selected suggestion */ .aa-cursor .algolia-docsearch-suggestion--content { color: #05A5D1; } .aa-cursor .algolia-docsearch-suggestion { background: hsl(198, 100%, 96%); } - -/* For bigger screens, when displaying results in two columns */ -@media (min-width: 768px) { - /* Bottom border of each suggestion */ - .algolia-docsearch-suggestion { - border-bottom-color: hsl(198, 100%, 94%); - } - /* Left column, with secondary category header */ - .algolia-docsearch-suggestion--subcategory-column { - border-right-color: hsl(198, 100%, 94%); - background-color: hsl(198, 100%, 96%); - color: #3B3738; - } +.algolia-docsearch-suggestion { + border-bottom-color: hsl(198, 100%, 94%); +} +.algolia-docsearch-suggestion--subcategory-column { + border-right-color: hsl(198, 100%, 94%); + background-color: hsl(198, 100%, 96%); + color: #3B3738; } diff --git a/docs/accessibility.html b/docs/accessibility.html index f402293d33f..a57629c12dc 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,6 +1,6 @@ -Accessibility – React Native | A framework for building native apps using React

Accessibility #

Edit on GitHub

Native App Accessibility (iOS and Android) #

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

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

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

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

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

Accessibility #

Edit on GitHub

Native App Accessibility (iOS and Android) #

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

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

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

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

<View accessible={true}> <Text>text one</Text> - <Text >text two</Text> + <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}> <View style={styles.button}> <Text style={styles.buttonText}>Press me!</Text> @@ -38,7 +38,7 @@ <CustomRadioButton accessibleComponentType={this.state.radioButton} - onPress={this._onPress}/>

In the above example we've created a custom radio button that now behaves like a native one. More specifically, TalkBack now correctly announces changes to the radio button selection.

Testing VoiceOver Support (iOS) #

To enable VoiceOver, go to the Settings app on your iOS device. Tap General, then Accessibility. There you will find many tools that people use to use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver.

To enable VoiceOver, tap on VoiceOver under "Vision" and toggle the switch that appears at the top.

At the very bottom of the Accessibility settings, there is an "Accessibility Shortcut". You can use this to toggle VoiceOver by triple clicking the Home button.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/actionsheetios.html b/docs/actionsheetios.html index 044268c6dd3..946cfb02416 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 #

Edit on GitHub

Methods #

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

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

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

ActionSheetIOS #

Edit on GitHub

Methods #

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

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

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

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

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

Examples #

Edit on GitHub
'use strict'; @@ -209,7 +209,7 @@ exports.examples return <ShareScreenshotExample />; } } -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/activityindicatorios.html b/docs/activityindicatorios.html index 3e410b52b11..31e8bd145f7 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 GitHub

Props #

animating bool #

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

color string #

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

hidesWhenStopped bool #

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

onLayout function #

Invoked on mount and layout changes with

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

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

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

Examples #

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

ActivityIndicatorIOS #

Edit on GitHub

Props #

animating bool #

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

color string #

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

hidesWhenStopped bool #

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

onLayout function #

Invoked on mount and layout changes with

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

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

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

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { @@ -144,7 +144,7 @@ exports.examples : 'row', justifyContent: 'space-around', }, -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/alert.html b/docs/alert.html index 4de75b57967..c26ca8b59b6 100644 --- a/docs/alert.html +++ b/docs/alert.html @@ -1,4 +1,4 @@ -Alert – React Native | A framework for building native apps using React

Alert #

Edit on GitHub

Launches an alert dialog with the specified title and message.

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

Alert #

Edit on GitHub

Launches an alert dialog with the specified title and message.

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

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

  • If you specify one butt module.exports = { AlertExample, SimpleAlertExampleBlock, -};
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/alertios.html b/docs/alertios.html index c4a6ecf505d..331e4e68958 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 #

Edit on GitHub

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

AlertIOS #

Edit on GitHub

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

AlertIOS.prompt allows you to prompt the user for input inside of an @@ -191,7 +191,7 @@ class PromptOptions extends : '#eeeeee', padding: 10, }, -});

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/android-building-from-source.html b/docs/android-building-from-source.html index 1c24e3023c7..5a83a2bc84d 100644 --- a/docs/android-building-from-source.html +++ b/docs/android-building-from-source.html @@ -1,6 +1,6 @@ -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 +Building React Native from source – React Native | A framework for building native apps using React

Building React Native from source #

Edit on GitHub

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

Prerequisites #

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

Make sure you have the following installed:

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

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

sdk.dir=absolute_path_to_android_sdk ndk.dir=absolute_path_to_android_ndk

Example:

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

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:

... +ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e

Download links for Android NDK #

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

You can find further instructions on the official page.

Building the source #

1. Installing the fork #

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

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

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

2. Adding gradle dependencies #

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

... dependencies { classpath 'com.android.tools.build:gradle:1.3.1' classpath 'de.undercouch:gradle-download-task:2.0.0' @@ -28,7 +28,7 @@ dependencies { rootProject.allprojects { buildDir = "/path/to/build/directory/${rootProject.name}/${project.name}" } -}

Troubleshooting #

Gradle build fails in ndk-build. See the section about local.properties file above.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/android-setup.html b/docs/android-setup.html index 0f240d07f42..eb53f40adb1 100644 --- a/docs/android-setup.html +++ b/docs/android-setup.html @@ -1,7 +1,7 @@ -Android Setup – React Native | A framework for building native apps using React

Android Setup #

Edit on GitHub

This guide describes basic steps of the Android development environment setup that are required to run React Native android apps on an android emulator.

Install Git #

  • On Mac, if you have installed XCode, Git is already installed, otherwise run the following:

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

  • On Windows, download and install Git for Windows. During the setup process, choose "Run Git from Windows Command Prompt", which will add Git to your PATH environment variable.

Install the Android SDK (unless you already have it) #

  1. Install the latest JDK
  2. Install the Android SDK:

Define the ANDROID_HOME environment variable #

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

For more information, see Apple's documentation

Basic Usage #

To see the current state, you can check AppStateIOS.currentState, which will be kept up-to-date. However, currentState will be null at launch while AppStateIOS retrieves it over the bridge.

getInitialState: function() { @@ -110,7 +111,7 @@ exports.examples : 'In the simulator, hit Shift+Command+M to simulate a memory warning.', render(): ReactElement { return <AppStateSubscription showMemoryWarnings={true} />; } }, -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html index ce32f5ea628..ca58ad4adc4 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 #

Edit on GitHub

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

AsyncStorage #

Edit on GitHub

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

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

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

Methods #

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

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

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

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

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

Returns a Promise object.

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

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

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

Erases all AsyncStorage for all clients, libraries, etc. You probably +Returns a Promise object. Not supported by all native implementations.

Example:

let UID123_object = { + name: 'Chris', + age: 30, + traits: {hair: 'brown', eyes: 'brown'}, +}; + +// need only define what will be added or updated +let UID123_delta = { + age: 31, + traits: {eyes: 'blue', shoe_size: 10} +}; + +AsyncStorage.setItem(store_key, JSON.stringify(UID123_object), () => { + AsyncStorage.mergeItem('UID123', JSON.stringify(UID123_delta), () => { + AsyncStorage.getItem('UID123', (err, result) => { + console.log(result); + // => {'name':'Chris','age':31,'traits':{'shoe_size':10,'hair':'brown','eyes':'blue'}} + }); + }); +});

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

Erases all AsyncStorage for all clients, libraries, etc. You probably 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 #

Examples #

Edit on GitHub
'use strict'; +own keys instead. Returns a Promise object.

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

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

Example: see multiGet for example

static flushGetRequests() #

Flushes any pending requests using a single multiget

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

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

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

Example:

AsyncStorage.getAllKeys((err, keys) => { + AsyncStorage.multiGet(keys, (err, stores) => { + stores.map((result, i, store) => { + // get at each store's key/value so you can work with it + let key = store[i][0]; + let value = store[i][1]; + }); + }); +});

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

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

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

Example: see multiMerge for an example

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

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

Example:

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

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

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

Not supported by all native implementations.

Example:

// first user, initial values +let UID234_object = { + name: 'Chris', + age: 30, + traits: {hair: 'brown', eyes: 'brown'}, +}; + +// first user, delta values +let UID234_delta = { + age: 31, + traits: {eyes: 'blue', shoe_size: 10}, +}; + +// second user, initial values +let UID345_object = { + name: 'Marge', + age: 25, + traits: {hair: 'blonde', eyes: 'blue'}, +}; + +// second user, delta values +let UID345_delta = { + age: 26, + traits: {eyes: 'green', shoe_size: 6}, +}; + +let multi_set_pairs = [['UID234', JSON.stringify(UID234_object)], ['UID345', JSON.stringify(UID345_object)]] +let multi_merge_pairs = [['UID234', JSON.stringify(UID234_delta)], ['UID345', JSON.stringify(UID345_delta)]] + +AsyncStorage.multiSet(multi_set_pairs, (err) => { + AsyncStorage.multiMerge(multi_merge_pairs, (err) => { + AsyncStorage.multiGet(['UID234','UID345'], (err, stores) => { + stores.map( (result, i, store) => { + let key = store[i][0]; + let val = store[i][1]; + console.log(key, val); + // => UID234 {"name":"Chris","age":31,"traits":{"shoe_size":10,"hair":"brown","eyes":"blue"}} + // => UID345 {"name":"Marge","age":26,"traits":{"shoe_size":6,"hair":"blonde","eyes":"green"}} + }); + }); + }); +});

Properties #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { @@ -114,7 +186,7 @@ exports.examples : 'Basics - getItem, setItem, removeItem', render(): ReactElement { return <BasicStorageExample />; } }, -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/backandroid.html b/docs/backandroid.html index 1def67335b2..3cab103b682 100644 --- a/docs/backandroid.html +++ b/docs/backandroid.html @@ -1,11 +1,11 @@ -BackAndroid – React Native | A framework for building native apps using React

BackAndroid #

Edit on GitHub

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

BackAndroid #

Edit on GitHub

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

Example:

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

Methods #

static exitApp() #

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

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

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/cameraroll.html b/docs/cameraroll.html index 531655fcbcc..eab0b90eee2 100644 --- a/docs/cameraroll.html +++ b/docs/cameraroll.html @@ -1,4 +1,4 @@ -CameraRoll – React Native | A framework for building native apps using React

CameraRoll #

Edit on GitHub

CameraRoll provides access to the local camera roll / gallery.

Methods #

static saveImageWithTag(tag) #

Saves the image to the camera roll / gallery.

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

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

Props #

dataSource ListViewDataSource #

initialListSize number #

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

Props #

dataSource ListViewDataSource #

enableEmptySections bool #

Flag indicating whether empty section headers should be rendered. In the future release +empty section headers will be rendered by default, and the flag will be deprecated. +If empty sections are not desired to be rendered their indices should be excluded from sectionID object.

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

scrollRenderAheadDistance number #

How early to start rendering rows before they come on screen, in -pixels.

iosstickyHeaderIndices [number] #

An array of child indices determining which children get docked to the +pixels.

iosstickyHeaderIndices [number] #

An array of child indices determining which children get docked to the top of the screen when scrolling. For example, passing stickyHeaderIndices={[0]} will cause the first child to be fixed to the top of the scroll view. This property is not supported in conjunction @@ -193,7 +195,7 @@ with horizontal={true}.

}, }); -module.exports = ListViewSimpleExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/mapview.html b/docs/mapview.html index 75118c98831..f6d7696c691 100644 --- a/docs/mapview.html +++ b/docs/mapview.html @@ -1,4 +1,4 @@ -MapView – React Native | A framework for building native apps using React

MapView #

Edit on GitHub

Props #

onAnnotationPress function #

Deprecated. Use annotation onFocus and onBlur instead.

onRegionChange function #

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

onRegionChangeComplete function #

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

pitchEnabled bool #

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

MapView #

Edit on GitHub

Props #

onAnnotationPress function #

Deprecated. Use annotation onFocus and onBlur instead.

onRegionChange function #

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

onRegionChangeComplete function #

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

pitchEnabled bool #

When this property is set to true and a valid camera is associated with the map, the camera’s pitch angle is used to tilt the plane of the map. When this property is set to false, the camera’s pitch angle is ignored and the map is always displayed as if the user @@ -12,7 +12,7 @@ Default value is true.

style View#style #

Used to style and layout the MapView. See StyleSheet.js and ViewStylePropTypes.js for more info.

zoomEnabled bool #

If false the user won't be able to pinch/zoom the map. -Default value is true.

androidactive bool #

iosannotations [{latitude: number, longitude: number, animateDrop: bool, draggable: bool, onDragStateChange: function, onFocus: function, onBlur: function, title: string, subtitle: string, leftCalloutView: element, rightCalloutView: element, detailCalloutView: element, tintColor: [object Object], image: Image.propTypes.source, view: element, id: string, hasLeftCallout: deprecatedPropType( +Default value is true.

androidactive bool #

iosannotations [{latitude: number, longitude: number, animateDrop: bool, draggable: bool, onDragStateChange: function, onFocus: function, onBlur: function, title: string, subtitle: string, leftCalloutView: element, rightCalloutView: element, detailCalloutView: element, tintColor: [object Object], image: Image.propTypes.source, view: element, id: string, hasLeftCallout: deprecatedPropType( React.PropTypes.bool, 'Use `leftCalloutView` instead.' ), hasRightCallout: deprecatedPropType( @@ -24,10 +24,10 @@ Default value is true.

#

Map annotations with title/subtitle.

iosfollowUserLocation bool #

If true the map will follow the user's location whenever it changes. +)}] #

Map annotations with title/subtitle.

iosfollowUserLocation bool #

If true the map will follow the user's location whenever it changes. 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. +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: [object Object], 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.

Examples #

Edit on GitHub
'use strict'; @@ -420,7 +420,7 @@ exports.examples />; } }, -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/modal.html b/docs/modal.html index 3926cccb28b..4944fa10788 100644 --- a/docs/modal.html +++ b/docs/modal.html @@ -1,16 +1,16 @@ -Modal – React Native | A framework for building native apps using React

Modal #

Edit on GitHub

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

Modal #

Edit on GitHub

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

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

In apps written with React Native from the root view down, you should use 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.

Props #

animated bool #

onDismiss function #

onShow function #

transparent bool #

visible bool #

Examples #

Edit on GitHub
'use strict'; +configureScene property.

Props #

animated bool #

onRequestClose function #

onShow function #

transparent bool #

visible bool #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { Modal, StyleSheet, - SwitchIOS, + Switch, Text, TouchableHighlight, View, @@ -87,7 +87,9 @@ exports.description ={this.state.animated} transparent={this.state.transparent} - visible={this.state.modalVisible}> + visible={this.state.modalVisible} + onRequestClose={() => {this._setModalVisible(false)}} + > <View style={[styles.container, modalBackgroundStyle]}> <View style={[styles.innerContainer, innerContainerTransparentStyle]}> <Text>This modal was presented {this.state.animated ? 'with' : 'without'} animation.</Text> @@ -102,12 +104,12 @@ exports.description ={styles.row}> <Text style={styles.rowTitle}>Animated</Text> - <SwitchIOS value={this.state.animated} onValueChange={this._toggleAnimated} /> + <Switch value={this.state.animated} onValueChange={this._toggleAnimated} /> </View> <View style={styles.row}> <Text style={styles.rowTitle}>Transparent</Text> - <SwitchIOS value={this.state.transparent} onValueChange={this._toggleTransparent} /> + <Switch value={this.state.transparent} onValueChange={this._toggleTransparent} /> </View> <Button onPress={this._setModalVisible.bind(this, true)}> @@ -162,7 +164,7 @@ exports.examples : { marginTop: 10, }, -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/native-components-android.html b/docs/native-components-android.html index 079d93628ba..7a7b1e40120 100644 --- a/docs/native-components-android.html +++ b/docs/native-components-android.html @@ -1,4 +1,4 @@ -Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

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

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

ImageView example #

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

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

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

Vending a view is simple:

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

1. Create the ViewManager subclass #

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

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

Native UI Components #

Edit on GitHub

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

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

ImageView example #

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

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

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

Vending a view is simple:

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

1. Create the ViewManager subclass #

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

... public class ReactImageManager extends SimpleViewManager<ReactImageView> { @@ -79,7 +79,7 @@ MyCustomView.propTypes var RCTMyCustomView = requireNativeComponent(`RCTMyCustomView`, MyCustomView, { nativeOnly: {onChange: true} -});

Note the use of nativeOnly above. Sometimes you'll have some special properties that you need to expose for the native component, but don't actually want them as part of the API for the associated React component. For example, Switch has a custom onChange handler for the raw native event, and exposes an onValueChange handler property that is invoked with just the boolean value rather than the raw event (similar to onChangeMessage in the example above). Since you don't want these native only properties to be part of the API, you don't want to put them in propTypes, but if you don't you'll get an error. The solution is simply to call them out via the nativeOnly option.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/native-components-ios.html b/docs/native-components-ios.html index fa709b8d47d..9abc5613eb0 100644 --- a/docs/native-components-ios.html +++ b/docs/native-components-ios.html @@ -1,4 +1,4 @@ -Native UI Components – React Native | A framework for building native apps using React

Native UI Components #

Edit on GitHub

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

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

iOS MapView example #

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

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

Vending a view is simple:

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

Native UI Components #

Edit on GitHub

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

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

iOS MapView example #

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

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

Vending a view is simple:

  • Create the basic subclass.
  • Add the RCT_EXPORT_MODULE() marker macro.
  • Implement the -(UIView *)view method
// RCTMapManager.m #import <MapKit/MapKit.h> #import "RCTViewManager.h" @@ -227,7 +227,7 @@ import { UIManager "datetime": @(UIDatePickerModeDateAndTime), } }; -}

This guide covered many of the aspects of bridging over custom native components, but there is even more you might need to consider, such as custom hooks for inserting and laying out subviews. If you want to go even deeper, check out the actual RCTMapManager and other components in the source code.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/native-modules-android.html b/docs/native-modules-android.html index 0999fc0fd3a..fa8aebcc732 100644 --- a/docs/native-modules-android.html +++ b/docs/native-modules-android.html @@ -1,4 +1,4 @@ -Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

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

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

The Toast Module #

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

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

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

Native Modules #

Edit on GitHub

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

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

The Toast Module #

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

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

package com.facebook.react.modules.toast; import android.widget.Toast; @@ -255,7 +255,7 @@ public void onHostPauseonHostDestroy() { // Actvity `onDestroy` -}
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/native-modules-ios.html b/docs/native-modules-ios.html index 9e2bcaab294..48dda167eb8 100644 --- a/docs/native-modules-ios.html +++ b/docs/native-modules-ios.html @@ -1,4 +1,4 @@ -Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

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

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

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

iOS Calendar Module Example #

This guide will use the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript.

A native module is just an Objective-C class that implements the RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.

// CalendarManager.h +Native Modules – React Native | A framework for building native apps using React

Native Modules #

Edit on GitHub

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

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

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

iOS Calendar Module Example #

This guide will use the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript.

A native module is just an Objective-C class that implements the RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.

// CalendarManager.h #import "RCTBridgeModule.h" @interface CalendarManager : NSObject <RCTBridgeModule> @@ -136,7 +136,7 @@ class CalendarManagerRCT_EXTERN_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(nonnull NSNumber *)date) @end

For those of you new to Swift and Objective-C, whenever you mix the two languages in an iOS project, you will also need an additional bridging file, known as a bridging header, to expose the Objective-C files to Swift. Xcode will offer to create this header file for you if you add your Swift file to your app through the Xcode File>New File menu option. You will need to import RCTBridgeModule.h in this header file.

// CalendarManager-Bridging-Header.h -#import "RCTBridgeModule.h"

You can also use RCT_EXTERN_REMAP_MODULE and RCT_EXTERN_REMAP_METHOD to alter the JavaScript name of the module or methods you are exporting. For more information see RCTBridgeModule.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/nativemethodsmixin.html b/docs/nativemethodsmixin.html index e24beb973ba..bc53650da24 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 #

Edit on GitHub

NativeMethodsMixin provides methods to access the underlying native +NativeMethodsMixin – React Native | A framework for building native apps using React

NativeMethodsMixin #

Edit on GitHub

NativeMethodsMixin provides methods to access the underlying native component directly. This can be useful in cases when you want to focus a view or measure its on-screen dimensions, for example.

The methods described here are available on most of the default components provided by React Native. Note, however, that they are not available on @@ -13,7 +13,7 @@ possible, consider using the < prop instead.

static measureInWindow(callback: MeasureInWindowOnSuccessCallback) #

Determines the location of the given view in the window and returns the values via an async callback. If the React root view is embedded in another native view, this will give you the absolute coordinates. If -successful, the callback will be called be called with the following +successful, the callback will be called with the following arguments:

  • x
  • y
  • width
  • height

Note that these measurements are not available until after the rendering has been completed in native.

static measureLayout(relativeToNativeNode: number, onSuccess: MeasureLayoutOnSuccessCallback, onFail: () => void) #

Like measure(), but measures the view relative an ancestor, specified as relativeToNativeNode. This means that the returned x, y @@ -22,7 +22,7 @@ are relative to the origin x, y of the ancestor view.

As always, to obtain future diff process - this means that if you do not include them in the next render, they will remain active (see Direct Manipulation).

static focus() #

Requests focus for the given input or view. The exact behavior triggered -will depend on the platform and type of view.

static blur() #

Removes focus from an input or view. This is the opposite of focus().

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/navigator-comparison.html b/docs/navigator-comparison.html index 03856c49c57..c82ab2a97bf 100644 --- a/docs/navigator-comparison.html +++ b/docs/navigator-comparison.html @@ -1,4 +1,4 @@ -Navigator Comparison – React Native | A framework for building native apps using React

Navigator Comparison #

Edit on GitHub

The differences between Navigator +Navigator Comparison – React Native | A framework for building native apps using React

Navigator Comparison #

Edit on GitHub

The differences between Navigator and NavigatorIOS are a common source of confusion for newcomers.

Both Navigator and NavigatorIOS are components that allow you to manage the navigation in your app between various "scenes" (another word @@ -12,7 +12,7 @@ class, and Navigator re-implements that functionality entirely in JavaScript as a React component. A corollary of this is that Navigator will be compatible with Android and iOS, whereas NavigatorIOS will only work on the one platform. Below is an itemized list of differences -between the two.

Navigator #

  • Extensive API makes it completely customizable from JavaScript.
  • Under active development from the React Native team.
  • Written in JavaScript.
  • Works on iOS and Android.
  • Includes a simple navigation bar component similar to the default NavigatorIOS bar: Navigator.NavigationBar, and another with breadcrumbs called Navigator.BreadcrumbNavigationBar. See the UIExplorer demo to try them out and see how to use them.
    • Currently animations are good and improving, but they are still less refined than Apple's, which you get from NavigatorIOS.
  • You can provide your own navigation bar by passing it through the navigationBar prop.

NavigatorIOS #

  • Small, limited API makes it much less customizable than Navigator in its current form.
  • Development belongs to open-source community - not used by the React Native team on their apps.
    • A result of this is that there is currently a backlog of unresolved bugs, nobody who uses this has stepped up to take ownership for it yet.
  • Wraps UIKit, so it works exactly the same as it would on another native app. Lives in Objective-C and JavaScript.
    • Consequently, you get the animations and behavior that Apple has developed.
  • iOS only.
  • Includes a navigation bar by default; this navigation bar is not a React Native view component and the style can only be slightly modified.

For most non-trivial apps, you will want to use Navigator - it won't be long before you run into issues when trying to do anything complex with NavigatorIOS.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/navigator.html b/docs/navigator.html index 2aade25270e..c08658df06f 100644 --- a/docs/navigator.html +++ b/docs/navigator.html @@ -1,4 +1,4 @@ -Navigator – React Native | A framework for building native apps using React

Navigator #

Edit on GitHub

Use Navigator to transition between different scenes in your app. To +Navigator – React Native | A framework for building native apps using React

Navigator #

Edit on GitHub

Use Navigator to transition between different scenes in your app. To accomplish this, provide route objects to the navigator to identify each scene, and also a renderScene function that the navigator can use to render the scene for a given route.

To change the animation or gesture properties of the scene, provide a @@ -33,13 +33,13 @@ 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 a route in the initialRouteStack if both props are provided. The -initialRoute will default to the last item in the initialRouteStack.

initialRouteStack [object] #

Provide a set of routes to initially mount. Required if no initialRoute +initialRoute will default to the last item in the initialRouteStack.

initialRouteStack [object] #

Provide a set of routes to initially mount. Required if no initialRoute is provided. Otherwise, it will default to an array containing only the initialRoute

navigationBar node #

Optionally provide a navigation bar that persists across scene transitions

navigator object #

Optionally provide the navigator object from a parent Navigator

onDidFocus function #

Will be called with the new route of each scene after the transition is complete or after the initial mounting

onWillFocus function #

Will emit the target route upon mounting and before each nav transition

renderScene function #

Required function which renders the scene for a given route. Will be invoked with the route and the navigator object

(route, navigator) => - <MySceneComponent title={route.title} navigator={navigator} />

sceneStyle View#style #

Styles to apply to the container of each scene

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/navigatorios.html b/docs/navigatorios.html index fb6c0c4a66b..e481b3ec0a2 100644 --- a/docs/navigatorios.html +++ b/docs/navigatorios.html @@ -1,4 +1,4 @@ -NavigatorIOS – React Native | A framework for building native apps using React

NavigatorIOS #

Edit on GitHub

NavigatorIOS wraps UIKit navigation and allows you to add back-swipe +NavigatorIOS – React Native | A framework for building native apps using React

NavigatorIOS #

Edit on GitHub

NavigatorIOS wraps UIKit navigation and allows you to add back-swipe functionality across your app.

NOTE: This Component is not maintained by Facebook

This component is under community responsibility. If a pure JavaScript solution fits your needs you may try the Navigator component instead.

Routes #

A route is an object used to describe each page in the navigator. The first @@ -285,7 +285,7 @@ const styles = StyleSheet}, }); -module.exports = NavigatorIOSExample;

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/netinfo.html b/docs/netinfo.html index 804f0d86116..708d68dc031 100644 --- a/docs/netinfo.html +++ b/docs/netinfo.html @@ -1,4 +1,4 @@ -NetInfo – React Native | A framework for building native apps using React

NetInfo #

Edit on GitHub

NetInfo exposes info about online/offline status

NetInfo.fetch().done((reach) => { +NetInfo – React Native | A framework for building native apps using React

NetInfo #

Edit on GitHub

NetInfo exposes info about online/offline status

NetInfo.fetch().done((reach) => { console.log('Initial: ' + reach); }); function handleFirstConnectivityChange(reach) { @@ -201,7 +201,7 @@ exports.examples : 'Asynchronously check isConnectionExpensive', render(): ReactElement { return <IsConnectionExpensive />; } }, -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/network.html b/docs/network.html index 3c9335de955..73b3bf92542 100644 --- a/docs/network.html +++ b/docs/network.html @@ -1,4 +1,4 @@ -Network – React Native | A framework for building native apps using React

Network #

Edit on GitHub

One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example.

Fetch #

fetch is a better networking API being worked on by the standards committee and is already available in Chrome. It is available in React Native by default.

Usage #

fetch('https://mywebsite.com/endpoint/')

Include a request object as the optional second argument to customize the HTTP request:

fetch('https://mywebsite.com/endpoint/', { +Network – React Native | A framework for building native apps using React

Network #

Edit on GitHub

One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example.

Fetch #

fetch is a better networking API being worked on by the standards committee and is already available in Chrome. It is available in React Native by default.

Usage #

fetch('https://mywebsite.com/endpoint/')

Include a request object as the optional second argument to customize the HTTP request:

fetch('https://mywebsite.com/endpoint/', { method: 'POST', headers: { 'Accept': 'application/json', @@ -62,7 +62,7 @@ request.onreadystatechange }; request.open('GET', 'https://mywebsite.com/endpoint.php'); -request.send();

Please follow the MDN Documentation for a complete description of the API.

As a developer, you're probably not going to use XMLHttpRequest directly as its API is very tedious to work with. But the fact that it is implemented and compatible with the browser API gives you the ability to use third-party libraries such as frisbee or axios directly from npm.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/panresponder.html b/docs/panresponder.html index ad2877dbf76..ce244128e0f 100644 --- a/docs/panresponder.html +++ b/docs/panresponder.html @@ -1,4 +1,4 @@ -PanResponder – React Native | A framework for building native apps using React

PanResponder #

Edit on GitHub

PanResponder reconciles several touches into a single gesture. It makes +PanResponder – React Native | A framework for building native apps using React

PanResponder #

Edit on GitHub

PanResponder reconciles several touches into a single gesture. It makes single-touch gestures resilient to extra touches, and can be used to recognize simple multi-touch gestures.

It provides a predictable wrapper of the responder handlers provided by the gesture responder system. @@ -185,7 +185,7 @@ are the responder.

},}); -module.exports = PanResponderExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/performance.html b/docs/performance.html index 067699e246d..1bf44fb9a5a 100644 --- a/docs/performance.html +++ b/docs/performance.html @@ -1,4 +1,4 @@ -Performance – React Native | A framework for building native apps using React

Performance #

Edit on GitHub

A compelling reason for using React Native instead of WebView-based +Performance – React Native | A framework for building native apps using React

Performance #

Edit on GitHub

A compelling reason for using React Native instead of WebView-based tools is to achieve 60 FPS and a native look & feel to your apps. Where possible, we would like for React Native to do the right thing and help you to focus on your app instead of performance optimization, but there @@ -184,7 +184,7 @@ inside of your onPress handler in requestAnimationFrame}); }

Profiling #

Use the built-in Profiler to get detailed information about work done in the JavaScript thread and main thread side-by-side.

For iOS, Instruments are an invaluable tool, and on Android you should -learn to use systrace.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/picker.html b/docs/picker.html index 0548073fa69..19d1c3f7233 100644 --- a/docs/picker.html +++ b/docs/picker.html @@ -1,4 +1,4 @@ -Picker – React Native | A framework for building native apps using React

Picker #

Edit on GitHub

Renders the native picker component on iOS and Android. Example:

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

Picker #

Edit on GitHub

Renders the native picker component on iOS and Android. Example:

<Picker selectedValue={this.state.language} onValueChange={(lang) => this.setState({language: lang})}> <Picker.Item label="Java" value="java" /> @@ -6,7 +6,7 @@ </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.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/pickerios.html b/docs/pickerios.html index 65f87c6dbde..7737c7b338d 100644 --- a/docs/pickerios.html +++ b/docs/pickerios.html @@ -1,4 +1,4 @@ -PickerIOS – React Native | A framework for building native apps using React

PickerIOS #

Edit on GitHub

Props #

itemStyle itemStylePropType #

onValueChange function #

selectedValue any #

Examples #

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

PickerIOS #

Edit on GitHub

Props #

itemStyle itemStylePropType #

onValueChange function #

selectedValue any #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { @@ -137,7 +137,7 @@ exports.examples : function(): ReactElement { return <PickerStyleExample />; }, -}];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/pixelratio.html b/docs/pixelratio.html index d6b998712a4..c829ad17c1d 100644 --- a/docs/pixelratio.html +++ b/docs/pixelratio.html @@ -1,4 +1,4 @@ -PixelRatio – React Native | A framework for building native apps using React

PixelRatio #

Edit on GitHub

PixelRatio class gives access to the device pixel density.

Fetching a correctly sized image #

You should get a higher resolution image if you are on a high pixel density +PixelRatio – React Native | A framework for building native apps using React

PixelRatio #

Edit on GitHub

PixelRatio class gives access to the device pixel density.

Fetching a correctly sized image #

You should get a higher resolution image if you are on a high pixel density device. A good rule of thumb is to multiply the size of the image you display by the pixel ratio.

var image = getImage({ width: PixelRatio.getPixelSizeForLayoutSize(200), @@ -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.

Description #

Edit on GitHub

Pixel Grid Snapping #

In iOS, you can specify positions and dimensions for elements with arbitrary precision, for example 29.674825. But, ultimately the physical display only have a fixed number of pixels, for example 640×960 for iphone 4 or 750×1334 for iphone 6. iOS tries to be as faithful as possible to the user value by spreading one original pixel into multiple ones to trick the eye. The downside of this technique is that it makes the resulting element look blurry.

In practice, we found out that developers do not want this feature and they have to work around it by doing manual rounding in order to avoid having blurry elements. In React Native, we are rounding all the pixels automatically.

We have to be careful when to do this rounding. You never want to work with rounded and unrounded values at the same time as you're going to accumulate rounding errors. Having even one rounding error is deadly because a one pixel border may vanish or be twice as big.

In React Native, everything in JS and within the layout engine work with arbitrary precision numbers. It's only when we set the position and dimensions of the native element on the main thread that we round. Also, rounding is done relative to the root rather than the parent, again to avoid accumulating rounding errors.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/platform-specific-code.html b/docs/platform-specific-code.html index 63b280e329e..53d8afe5ab7 100644 --- a/docs/platform-specific-code.html +++ b/docs/platform-specific-code.html @@ -1,4 +1,4 @@ -Platform Specific Code – React Native | A framework for building native apps using React

Platform Specific Code #

Edit on GitHub

When building a cross-platform app, the need to write different code for different platforms may arise. This can always be achieved by organizing the various components in different folders:

/common/components/ +Platform Specific Code – React Native | A framework for building native apps using React

Platform Specific Code #

Edit on GitHub

When building a cross-platform app, the need to write different code for different platforms may arise. This can always be achieved by organizing the various components in different folders:

/common/components/ /android/components/ /ios/components/

Another option may be naming the components differently depending on the platform they are going to be used in:

BigButtonIOS.js BigButtonAndroid.js

But React Native provides two alternatives to easily organize your code separating it by platform:

Platform specific extensions #

React Native will detect when a file has a .ios. or .android. extension and load the right file for each platform when requiring them from other components.

For example, you can have these files in your project:

BigButton.ios.js @@ -10,7 +10,7 @@ BigButton.androidif(Platform.Version === 21){ console.log('Running on Lollipop!'); -}
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/progressbarandroid.html b/docs/progressbarandroid.html index 3b8a6f31ccd..1f99aecad86 100644 --- a/docs/progressbarandroid.html +++ b/docs/progressbarandroid.html @@ -1,4 +1,4 @@ -ProgressBarAndroid – React Native | A framework for building native apps using React

ProgressBarAndroid #

Edit on GitHub

React component that wraps the Android-only ProgressBar. This component is used to indicate +ProgressBarAndroid – React Native | A framework for building native apps using React

ProgressBarAndroid #

Edit on GitHub

React component that wraps the Android-only ProgressBar. This component is used to indicate that the app is loading or there is some activity in the app.

Example:

render: function() { var progressBar = <View style={styles.container}> @@ -108,7 +108,7 @@ can only be false if styleAttr is Horizontal.

< }, }); -module.exports = ProgressBarAndroidExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/progressviewios.html b/docs/progressviewios.html index eff1a274f31..07879424097 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 #

Edit on GitHub

Use ProgressViewIOS to render a UIProgressView on iOS.

Props #

progress number #

The progress value (between 0 and 1).

progressImage Image.propTypes.source #

A stretchable image to display as the progress bar.

progressTintColor string #

The tint color of the progress bar itself.

progressViewStyle enum('default', 'bar') #

The progress bar style.

trackImage Image.propTypes.source #

A stretchable image to display behind the progress bar.

trackTintColor string #

The tint color of the progress bar track.

Examples #

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

ProgressViewIOS #

Edit on GitHub

Use ProgressViewIOS to render a UIProgressView on iOS.

Props #

progress number #

The progress value (between 0 and 1).

progressImage Image.propTypes.source #

A stretchable image to display as the progress bar.

progressTintColor string #

The tint color of the progress bar itself.

progressViewStyle enum('default', 'bar') #

The progress bar style.

trackImage Image.propTypes.source #

A stretchable image to display behind the progress bar.

trackTintColor string #

The tint color of the progress bar track.

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { @@ -66,7 +66,7 @@ exports.examples : { marginTop: 20, } -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/pushnotificationios.html b/docs/pushnotificationios.html index c6120570844..33b4fbbcc8e 100644 --- a/docs/pushnotificationios.html +++ b/docs/pushnotificationios.html @@ -1,4 +1,4 @@ -PushNotificationIOS – React Native | A framework for building native apps using React

PushNotificationIOS #

Edit on GitHub

Handle push notifications for your app, including permission handling and +PushNotificationIOS – React Native | A framework for building native apps using React

PushNotificationIOS #

Edit on GitHub

Handle push notifications for your app, including permission handling and icon badge number.

To get up and running, configure your notifications with Apple and your server-side system. To get an idea, this is the Parse guide.

Manually link the PushNotificationIOS library

  • Be sure to add the following to your Header Search Paths: $(SRCROOT)/../node_modules/react-native/Libraries/PushNotificationIOS
  • Set the search to recursive

Finally, to enable support for notification and register events you need to augment your AppDelegate.

At the top of your AppDelegate.m:

#import "RCTPushNotificationManager.h"

And then in your AppDelegate implementation add the following:

// Required to register for notifications @@ -186,7 +186,7 @@ exports.examples render(): ReactElement { return <NotificationPermissionExample />; } -}];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/refreshcontrol.html b/docs/refreshcontrol.html index 2a8d724d8b4..8d0a6a56744 100644 --- a/docs/refreshcontrol.html +++ b/docs/refreshcontrol.html @@ -1,6 +1,38 @@ -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 +RefreshControl – React Native | A framework for building native apps using React

RefreshControl #

Edit on GitHub

This component is used inside a ScrollView or ListView to add pull to refresh functionality. When the ScrollView is at scrollY: 0, swiping down -triggers an onRefresh event.

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'; +triggers an onRefresh event.

Usage example #

class RefreshableList extends Component { + constructor(props) { + super(props); + this.state = { + refreshing: false, + }; + } + + _onRefresh() { + this.setState({refreshing: true}); + fetchData().then(() => { + this.setState({refreshing: false}); + }); + } + + render() { + return ( + <ListView + refreshControl={ + <RefreshControl + refreshing={this.state.refreshing} + onRefresh={this._onRefresh.bind(this)} + /> + } + ... + > + ... + </ListView> + ); + } + ... +}

Note: refreshing is a controlled prop, this is why it needs to be set to true +in the onRefresh function otherwise the refresh indicator will stop immediatly.

Props #

onRefresh function #

Called when the view starts refreshing.

refreshing bool #

Whether the view should be indicating an active refresh.

androidcolors [color] #

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

androidenabled bool #

Whether the pull to refresh functionality is enabled.

androidprogressBackgroundColor color #

The background color of the refresh indicator.

androidsize RefreshLayoutConsts.SIZE.DEFAULT #

Size of the refresh indicator, see RefreshControl.SIZE.

iostintColor color #

The color of the refresh indicator.

iostitle string #

The title displayed under the refresh indicator.

Examples #

Edit on GitHub
'use strict'; const React = require('react-native'); const { @@ -110,7 +142,7 @@ const RefreshControlExample = React}, }); -module.exports = RefreshControlExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/running-on-device-android.html b/docs/running-on-device-android.html index d217bfae812..aa3f301b322 100644 --- a/docs/running-on-device-android.html +++ b/docs/running-on-device-android.html @@ -1,7 +1,7 @@ -Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Prerequisite: USB Debugging #

You'll need this in order to install your app on your device. First, make sure you have USB debugging enabled on your device.

Check that your device has been successfully connected by running adb devices:

$ adb devices +Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Prerequisite: USB Debugging #

You'll need this in order to install your app on your device. First, make sure you have USB debugging enabled on your device.

Check that your device has been successfully connected by running adb devices:

$ adb devices List of devices attached emulator-5554 offline # Google emulator -14ed2fcc device # Physical device

Seeing device in the right column means the device is connected. Android - go figure :) You must have only one device connected.

Now you can use react-native run-android to install and launch your app on the device.

Accessing development server from device #

You can also iterate quickly on device using the development server. Follow one of the steps described below to make your development server running on your laptop accessible for your device.

Hint

Most modern android devices don't have a hardware menu button, which we use to trigger the developer menu. In that case you can shake the device to open the dev menu (to reload, debug, etc.). Alternatively, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).

Using adb reverse #

Note that this option is available on devices running android 5.0+ (API 21).

Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).

  1. Run adb reverse tcp:8081 tcp:8081
  2. You can use Reload JS and other development options with no extra configuration

Configure your app to connect to the local dev server via Wi-Fi #

  1. Make sure your laptop and your phone are on the same Wi-Fi network.
  2. Open your React Native app on your device. You can do this the same way you'd open any other app.
  3. You'll see a red screen with an error. This is OK. The following steps will fix that.
  4. Open the Developer menu by shaking the device or running adb shell input keyevent 82 from the command line.
  5. Go to Dev Settings.
  6. Go to Debug server host for device.
  7. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). On Mac, you can find the IP address in System Preferences / Network. On Windows, open the command prompt and type ipconfig to find your machine's IP address (more info).
  8. Go back to the Developer menu and select Reload JS.
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/running-on-device-ios.html b/docs/running-on-device-ios.html index 0241c5020ac..0851dba3248 100644 --- a/docs/running-on-device-ios.html +++ b/docs/running-on-device-ios.html @@ -1,4 +1,4 @@ -Running On Device – React Native | A framework for building native apps using React

Running On Device #

Edit on GitHub

Note that running on device requires Apple Developer account and provisioning your iPhone. This guide covers only React Native specific topic.

Accessing development server from device #

You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Change the IP in the URL from localhost to your laptop's IP. On Mac, you can find the IP address in System Preferences / Network.
  3. In Xcode select your phone as build target and press "Build and run"

Hint

Shake the device to open development menu (reload, debug, etc.)

Using offline bundle #

When you run your app on device, we pack all the JavaScript code and the images used into the app's resources. This way you can test it without development server running and submit the app to the AppStore.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Uncomment jsCodeLocation = [[NSBundle mainBundle] ...
  3. The JS bundle will be built for dev or prod depending on your app's scheme (Debug = development build with warnings, Release = minified prod build with perf optimizations). To change the scheme navigate to Product > Scheme > Edit Scheme... in xcode and change Build Configuration between Debug and Release.

Disabling in-app developer menu #

When building your app for production, your app's scheme should be set to Release as detailed in the debugging documentation in order to disable the in-app developer menu.

Troubleshooting #

If curl command fails make sure the packager is running. Also try adding --ipv4 flag to the end of it.

Note that since v0.14 JS and images are automatically packaged into the iOS app using Bundle React Native code and images Xcode build phase.

© 2016 Facebook Inc.

Running On Device #

Edit on GitHub

Note that running on device requires Apple Developer account and provisioning your iPhone. This guide covers only React Native specific topic.

Accessing development server from device #

You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Change the IP in the URL from localhost to your laptop's IP. On Mac, you can find the IP address in System Preferences / Network.
  3. In Xcode select your phone as build target and press "Build and run"

Hint

Shake the device to open development menu (reload, debug, etc.)

Using offline bundle #

When you run your app on device, we pack all the JavaScript code and the images used into the app's resources. This way you can test it without development server running and submit the app to the AppStore.

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. Uncomment jsCodeLocation = [[NSBundle mainBundle] ...
  3. The JS bundle will be built for dev or prod depending on your app's scheme (Debug = development build with warnings, Release = minified prod build with perf optimizations). To change the scheme navigate to Product > Scheme > Edit Scheme... in xcode and change Build Configuration between Debug and Release.

Disabling in-app developer menu #

When building your app for production, your app's scheme should be set to Release as detailed in the debugging documentation in order to disable the in-app developer menu.

Troubleshooting #

If curl command fails make sure the packager is running. Also try adding --ipv4 flag to the end of it.

Note that since v0.14 JS and images are automatically packaged into the iOS app using Bundle React Native code and images Xcode build phase.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/scrollview.html b/docs/scrollview.html index 464f6ba8d04..2d0860eb650 100644 --- a/docs/scrollview.html +++ b/docs/scrollview.html @@ -1,4 +1,4 @@ -ScrollView – React Native | A framework for building native apps using React

ScrollView #

Edit on GitHub

Component that wraps platform ScrollView while providing +ScrollView – React Native | A framework for building native apps using React

ScrollView #

Edit on GitHub

Component that wraps platform ScrollView while providing integration with touch locking "responder" system.

Keep in mind that ScrollViews must have a bounded height in order to work, since they contain unbounded-height children into a bounded container (via a scroll interaction). In order to bound the height of a ScrollView, either @@ -60,19 +60,22 @@ decelerates after the user lifts their finger. You may also use string shortcuts "normal" and "fast" which match the underlying iOS settings for UIScrollViewDecelerationRateNormal and UIScrollViewDecelerationRateFast respectively. - - Normal: 0.998 (the default) - - Fast: 0.9

iosdirectionalLockEnabled bool #

When true, the ScrollView will try to lock to only vertical or horizontal + - normal: 0.998 (the default) + - fast: 0.99

iosdirectionalLockEnabled bool #

When true, the ScrollView will try to lock to only vertical or horizontal scrolling while dragging. The default value is false.

iosindicatorStyle enum('default', 'black', 'white') #

The style of the scroll indicators. - default (the default), same as black. - black, scroll indicator is black. This style is good against a white content background. - white, scroll indicator is white. This style is good against a black content background.

iosmaximumZoomScale number #

The maximum allowed zoom scale. The default value is 1.0.

iosminimumZoomScale number #

The minimum allowed zoom scale. The default value is 1.0.

iosonRefreshStart function #

Deprecated

Use the refreshControl prop instead.

iosonScrollAnimationEnd function #

Called when a scrolling animation ends.

iospagingEnabled bool #

When true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination. The default value is false.

iosscrollEventThrottle number #

This controls how often the scroll event will be fired while scrolling -(in events per seconds). A higher number yields better accuracy for code +(as a time interval in ms). A lower number yields better accuracy for code that is tracking the scroll position, but can lead to scroll performance problems due to the volume of information being send over the bridge. -The default value is zero, which means the scroll event will be sent -only once each time the view is scrolled.

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

The amount by which the scroll view indicators are inset from the edges +You will not notice a difference between values set between 1-16 as the +JS run loop is synced to the screen refresh rate. If you do not need precise +scroll position tracking, set this value higher to limit the information +being sent across the bridge. The default value is zero, which results in +the scroll event being sent only once each time the view is scrolled.

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

The amount by which the scroll view indicators are inset from the edges of the scroll view. This should normally be set to the same value as the contentInset. Defaults to {0, 0, 0, 0}.

iosscrollsToTop bool #

When true, the scroll view scrolls to top when the status bar is tapped. The default value is true.

iossnapToAlignment enum('start', 'center', 'end') #

When snapToInterval is set, snapToAlignment will define the relationship @@ -82,7 +85,7 @@ of the snapping to the scroll view. - end will align the snap at the right (horizontal) or bottom (vertical)

iossnapToInterval number #

When set, causes the scroll view to stop at multiples of the value of snapToInterval. This can be used for paginating through children that have lengths smaller than the scroll view. Used in combination -with snapToAlignment.

iosstickyHeaderIndices [number] #

An array of child indices determining which children get docked to the +with snapToAlignment.

iosstickyHeaderIndices [number] #

An array of child indices determining which children get docked to the top of the screen when scrolling. For example, passing stickyHeaderIndices={[0]} will cause the first child to be fixed to the top of the scroll view. This property is not supported in conjunction @@ -203,7 +206,7 @@ THUMBS = THUMBS: 64, height: 64, } -});

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/segmentedcontrolios.html b/docs/segmentedcontrolios.html index ddaa010788a..a99f1894c8c 100644 --- a/docs/segmentedcontrolios.html +++ b/docs/segmentedcontrolios.html @@ -1,8 +1,17 @@ -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. +SegmentedControlIOS – React Native | A framework for building native apps using React

SegmentedControlIOS #

Edit on GitHub

Use SegmentedControlIOS to render a UISegmentedControl iOS.

Programmatically changing selected index #

The selected index can be changed on the fly by assigning the +selectIndex prop to a state variable, then changing that variable. +Note that the state variable would need to be updated as the user +selects a value and changes the index, as shown in the example below.

<SegmentedControlIOS + values={['One', 'Two']} + selectedIndex={this.state.selectedIndex} + onChange={(event) => { + this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex}); + }} +/>

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.

Examples #

Edit on GitHub
'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 { @@ -155,7 +164,7 @@ exports.examples : 'Change events can be detected', render(): ReactElement { return <EventSegmentedControlExample />; } } -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/shadowproptypesios.html b/docs/shadowproptypesios.html index a59f4568e73..3da1ffb5efb 100644 --- a/docs/shadowproptypesios.html +++ b/docs/shadowproptypesios.html @@ -1,4 +1,4 @@ -ShadowPropTypesIOS – React Native | A framework for building native apps using React

ShadowPropTypesIOS #

Edit on GitHub

Props #

shadowColor color #

shadowOffset {width: number, height: number} #

shadowOpacity number #

shadowRadius number #

© 2016 Facebook Inc.

ShadowPropTypesIOS #

Edit on GitHub

Props #

shadowColor color #

shadowOffset {width: number, height: number} #

shadowOpacity number #

shadowRadius number #

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/signed-apk-android.html b/docs/signed-apk-android.html index abd059e580b..0563bfd60a2 100644 --- a/docs/signed-apk-android.html +++ b/docs/signed-apk-android.html @@ -1,4 +1,4 @@ -Generating Signed APK – React Native | A framework for building native apps using React

Generating Signed APK #

Edit on GitHub

To distribute your Android application via Google Play store, you'll need to generate a signed release APK. The Signing Your Applications page on Android Developers documentation describes the topic in detail. This guide covers the process in brief, as well as lists the steps required to packaging the JavaScript bundle.

Generating a signing key #

You can generate a private signing key using keytool.

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This command prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore.

The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.

Note: Remember to keep your keystore file private and never commit it to version control.

Setting up gradle variables #

  1. Place the my-release-key.keystore file under the android/app directory in your project folder.
  2. Edit the file ~/.gradle/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore +Generating Signed APK – React Native | A framework for building native apps using React

Generating Signed APK #

Edit on GitHub

To distribute your Android application via Google Play store, you'll need to generate a signed release APK. The Signing Your Applications page on Android Developers documentation describes the topic in detail. This guide covers the process in brief, as well as lists the steps required to packaging the JavaScript bundle.

Generating a signing key #

You can generate a private signing key using keytool.

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This command prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore.

The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.

Note: Remember to keep your keystore file private and never commit it to version control.

Setting up gradle variables #

  1. Place the my-release-key.keystore file under the android/app directory in your project folder.
  2. Edit the file ~/.gradle/gradle.properties and add the following (replace ***** with the correct keystore password, alias and key password),
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore MYAPP_RELEASE_KEY_ALIAS=my-key-alias MYAPP_RELEASE_STORE_PASSWORD=***** MYAPP_RELEASE_KEY_PASSWORD=*****

These are going to be global gradle variables, which we can later use in our gradle config to sign our app.

Note: Once you publish the app on the Play Store, you will need to republish your app under a different package name (losing all downloads and ratings) if you want to change the signing key at any point. So backup your keystore and don't forget the passwords.

Adding signing config to your app's gradle config #

Edit the file android/app/build.gradle in your project folder and add the signing config,

... @@ -23,7 +23,7 @@ android { ...

Generating the release APK #

Simply run the following in a terminal:

$ cd android && ./gradlew assembleRelease

Gradle's assembleRelease will bundle all the JavaScript needed to run your app into the APK. If you need to change the way the JavaScript bundle and/or drawable resources are bundled (e.g. if you changed the default file/folder names or the general structure of the project), have a look at android/app/build.gradle to see how you can update it to reflect these changes.

The generated APK can be found under android/app/build/outputs/apk/app-release.apk, and is ready to be distributed.

Testing the release build of your app #

Before uploading the release build to the Play Store, make sure you test it thoroughly. Install it on the device using:

$ cd android && ./gradlew installRelease

Note that installRelease is only available if you've set up signing as described above.

You can kill any running packager instances, all your and framework JavaScript code is bundled in the APK's assets.

Enabling Proguard to reduce the size of the APK (optional) #

Proguard is a tool that can slightly reduce the size of the APK. It does this by stripping parts of the React Native Java bytecode (and its dependencies) that your app is not using.

IMPORTANT: Make sure to thoroughly test your app if you've enabled Proguard. Proguard often requires configuration specific to each native library you're using. See app/proguard-rules.pro.

To enable Proguard, edit android/app/build.gradle:

/** * Run Proguard to shrink the Java bytecode in release builds. */ -def enableProguardInReleaseBuilds = true
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/sliderios.html b/docs/sliderios.html index 0740af6396e..276dd4b517c 100644 --- a/docs/sliderios.html +++ b/docs/sliderios.html @@ -1,4 +1,4 @@ -SliderIOS – React Native | A framework for building native apps using React

SliderIOS #

Edit on GitHub

Props #

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 @@ -116,7 +116,7 @@ exports.examples ); } }, -];

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/statusbar.html b/docs/statusbar.html index 5bb577c14ef..87a4942d5a7 100644 --- a/docs/statusbar.html +++ b/docs/statusbar.html @@ -1,4 +1,4 @@ -StatusBar – React Native | A framework for building native apps using React

StatusBar #

Edit on GitHub

Component to control the app status bar.

Usage with Navigator #

It is possible to have multiple StatusBar components mounted at the same +StatusBar – React Native | A framework for building native apps using React

StatusBar #

Edit on GitHub

Component to control the app status bar.

Usage with Navigator #

It is possible to have multiple StatusBar components mounted at the same time. The props will be merged in the order the StatusBar components were mounted. One use case is to specify status bar styles per route using Navigator.

<View> <StatusBar @@ -26,26 +26,13 @@ prop. Defaults to 'fade'.

=require('react-native'); const { + StatusBar, StyleSheet, - View, Text, TouchableHighlight, - StatusBar, + View,}= React; -type BarStyle ='default'|'light-content'; -type ShowHideTransition ='fade'|'slide'; - -type State ={ - animated: boolean, - backgroundColor: string, - hidden?: boolean, - showHideTransition: ShowHideTransition, - translucent?: boolean, - barStyle?: BarStyle, - networkActivityIndicatorVisible?: boolean -}; - exports.framework ='React'; exports.title ='<StatusBar>'; exports.description ='Component for controlling the status bar'; @@ -66,242 +53,412 @@ const showHideTransitions ='slide',]; -functiongetValue(values: Array<any>, index: number): any { +function getValue<T>(values: Array<T>, index: number): T {return values[index % values.length];} -const StatusBarExample = React.createClass({ - getInitialState(): State { +const StatusBarHiddenExample = React.createClass({ + getInitialState(){return{ animated:true, - backgroundColor:getValue(colors,0), + hidden:false, showHideTransition:getValue(showHideTransitions,0),};}, - _colorIndex:0, - _barStyleIndex:0, _showHideTransitionIndex:0, + _onChangeAnimated(){ + this.setState({animated:!this.state.animated}); + }, + + _onChangeHidden(){ + this.setState({hidden:!this.state.hidden}); + }, + + _onChangeTransition(){ + this._showHideTransitionIndex++; + this.setState({ + showHideTransition:getValue(showHideTransitions,this._showHideTransitionIndex), + }); + }, + + render(){ + return( + <View> + <StatusBar + hidden={this.state.hidden} + showHideTransition={this.state.showHideTransition} + animated={this.state.animated} + /> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeHidden}> + <View style={styles.button}> + <Text>hidden:{this.state.hidden ?'true':'false'}</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeAnimated}> + <View style={styles.button}> + <Text>animated (ios only):{this.state.animated ?'true':'false'}</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeTransition}> + <View style={styles.button}> + <Text> + showHideTransition (ios only): + '{getValue(showHideTransitions, this._showHideTransitionIndex)}' + </Text> + </View> + </TouchableHighlight> + </View> + ); + }, +}); + +const StatusBarStyleExample = React.createClass({ + getInitialState(){ + return{ + animated:true, + barStyle:getValue(barStyles,this._barStyleIndex), + }; + }, + + _barStyleIndex:0, + + _onChangeBarStyle(){ + this._barStyleIndex++; + this.setState({barStyle:getValue(barStyles,this._barStyleIndex)}); + }, + + _onChangeAnimated(){ + this.setState({animated:!this.state.animated}); + }, + + render(){ + return( + <View> + <StatusBar + animated={this.state.animated} + barStyle={this.state.barStyle} + /> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeBarStyle}> + <View style={styles.button}> + <Text>style:'{getValue(barStyles, this._barStyleIndex)}'</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeAnimated}> + <View style={styles.button}> + <Text>animated:{this.state.animated ?'true':'false'}</Text> + </View> + </TouchableHighlight> + </View> + ); + }, +}); + +const StatusBarNetworkActivityExample = React.createClass({ + getInitialState(){ + return{ + networkActivityIndicatorVisible:false, + }; + }, + + _onChangeNetworkIndicatorVisible(){ + this.setState({ + networkActivityIndicatorVisible:!this.state.networkActivityIndicatorVisible, + }); + }, + + render(){ + return( + <View> + <StatusBar + networkActivityIndicatorVisible={this.state.networkActivityIndicatorVisible} + /> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeNetworkIndicatorVisible}> + <View style={styles.button}> + <Text> + networkActivityIndicatorVisible: + {this.state.networkActivityIndicatorVisible ?'true':'false'} + </Text> + </View> + </TouchableHighlight> + </View> + ); + }, +}); + +const StatusBarBackgroundColorExample = React.createClass({ + getInitialState(){ + return{ + animated:true, + backgroundColor:getValue(colors,0), + }; + }, + + _colorIndex:0, + + _onChangeBackgroundColor(){ + this._colorIndex++; + this.setState({backgroundColor:getValue(colors,this._colorIndex)}); + }, + + _onChangeAnimated(){ + this.setState({animated:!this.state.animated}); + }, + render(){return( <View> <StatusBar backgroundColor={this.state.backgroundColor} - translucent={this.state.translucent} - hidden={this.state.hidden} - showHideTransition={this.state.showHideTransition} animated={this.state.animated} - barStyle={this.state.barStyle} - networkActivityIndicatorVisible={this.state.networkActivityIndicatorVisible}/> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>this.setState({animated:!this.state.animated})}> - <View style={styles.button}> - <Text>animated:{this.state.animated ?'true':'false'}</Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>this.setState({hidden:!this.state.hidden})}> - <View style={styles.button}> - <Text>hidden:{this.state.hidden ?'true':'false'}</Text> - </View> - </TouchableHighlight> - </View> - <Text style={styles.title}>iOS</Text> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this._barStyleIndex++; - this.setState({barStyle:getValue(barStyles,this._barStyleIndex)}); - }}> - <View style={styles.button}> - <Text>style:'{getValue(barStyles, this._barStyleIndex)}'</Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>this.setState({ - networkActivityIndicatorVisible:!this.state.networkActivityIndicatorVisible, - })}> - <View style={styles.button}> - <Text> - networkActivityIndicatorVisible: - {this.state.networkActivityIndicatorVisible ?'true':'false'} - </Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this._showHideTransitionIndex++; - this.setState({ - showHideTransition: - getValue(showHideTransitions,this._showHideTransitionIndex), - }); - }}> - <View style={styles.button}> - <Text> - showHideTransition: - '{getValue(showHideTransitions, this._showHideTransitionIndex)}' - </Text> - </View> - </TouchableHighlight> - </View> - <Text style={styles.title}>Android</Text> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this._colorIndex++; - this.setState({backgroundColor:getValue(colors,this._colorIndex)}); - }}> - <View style={styles.button}> - <Text>backgroundColor:'{getValue(colors, this._colorIndex)}'</Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this.setState({ - translucent:!this.state.translucent, - backgroundColor:!this.state.translucent ?'rgba(0, 0, 0, 0.4)':'black', - }); - }}> - <View style={styles.button}> - <Text>translucent:{this.state.translucent ?'true':'false'}</Text> - </View> - </TouchableHighlight> - </View> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeBackgroundColor}> + <View style={styles.button}> + <Text>backgroundColor:'{getValue(colors, this._colorIndex)}'</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeAnimated}> + <View style={styles.button}> + <Text>animated:{this.state.animated ?'true':'false'}</Text> + </View> + </TouchableHighlight> </View>);},}); -const StatusBarStaticExample = React.createClass({ - _colorIndex:0, - _barStyleIndex:0, - _showHideTransitionIndex:0, +const StatusBarTranslucentExample = React.createClass({getInitialState(){return{ - backgroundColor:getValue(colors,0), - barStyle:getValue(barStyles,0), - hidden:false, - networkActivityIndicatorVisible:false, translucent:false,};}, + _onChangeTranslucent(){ + this.setState({ + translucent:!this.state.translucent, + }); + }, + render(){return( <View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - const hidden =!this.state.hidden; - StatusBar.setHidden(hidden,'slide'); - this.setState({hidden}); - }}> - <View style={styles.button}> - <Text>hidden:{this.state.hidden ?'true':'false'}</Text> - </View> - </TouchableHighlight> - </View> - <Text style={styles.title}>iOS</Text> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this._barStyleIndex++; - const barStyle =getValue(barStyles,this._barStyleIndex); - StatusBar.setBarStyle(barStyle,true); - this.setState({barStyle}); - }}> - <View style={styles.button}> - <Text>style:'{getValue(barStyles, this._barStyleIndex)}'</Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - const networkActivityIndicatorVisible =!this.state.networkActivityIndicatorVisible; - StatusBar.setNetworkActivityIndicatorVisible(networkActivityIndicatorVisible); - this.setState({networkActivityIndicatorVisible}); - }}> - <View style={styles.button}> - <Text> - networkActivityIndicatorVisible: - {this.state.networkActivityIndicatorVisible ?'true':'false'} - </Text> - </View> - </TouchableHighlight> - </View> - <Text style={styles.title}>Android</Text> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - this._colorIndex++; - const backgroundColor =getValue(colors,this._colorIndex); - StatusBar.setBackgroundColor(backgroundColor,true); - this.setState({backgroundColor}); - }}> - <View style={styles.button}> - <Text>backgroundColor:'{getValue(colors, this._colorIndex)}'</Text> - </View> - </TouchableHighlight> - </View> - <View> - <TouchableHighlight - style={styles.wrapper} - onPress={()=>{ - const translucent =!this.state.translucent; - const backgroundColor =!this.state.translucent ?'rgba(0, 0, 0, 0.4)':'black'; - StatusBar.setTranslucent(translucent); - StatusBar.setBackgroundColor(backgroundColor,true); - this.setState({ - translucent, - backgroundColor, - }); - }}> - <View style={styles.button}> - <Text>translucent:{this.state.translucent ?'true':'false'}</Text> - </View> - </TouchableHighlight> - </View> + <StatusBar + translucent={this.state.translucent} + /> + <TouchableHighlight + style={styles.wrapper} + onPress={this._onChangeTranslucent}> + <View style={styles.button}> + <Text>translucent:{this.state.translucent ?'true':'false'}</Text> + </View> + </TouchableHighlight> </View>);},}); -exports.examples =[{ - title:'StatusBar', +const StatusBarStaticIOSExample = React.createClass({render(){ - return <StatusBarExample />; + return( + <View> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setHidden(true,'slide'); + }}> + <View style={styles.button}> + <Text>setHidden(true,'slide')</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setHidden(false,'fade'); + }}> + <View style={styles.button}> + <Text>setHidden(false,'fade')</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setBarStyle('default',true); + }}> + <View style={styles.button}> + <Text>setBarStyle('default',true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setBarStyle('light-content',true); + }}> + <View style={styles.button}> + <Text>setBarStyle('light-content',true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setNetworkActivityIndicatorVisible(true); + }}> + <View style={styles.button}> + <Text>setNetworkActivityIndicatorVisible(true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setNetworkActivityIndicatorVisible(false); + }}> + <View style={styles.button}> + <Text>setNetworkActivityIndicatorVisible(false)</Text> + </View> + </TouchableHighlight> + </View> + );}, +}); + +const StatusBarStaticAndroidExample = React.createClass({ + render(){ + return( + <View> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setHidden(true); + }}> + <View style={styles.button}> + <Text>setHidden(true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setHidden(false); + }}> + <View style={styles.button}> + <Text>setHidden(false)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setBackgroundColor('#ff00ff',true); + }}> + <View style={styles.button}> + <Text>setBackgroundColor('#ff00ff',true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setBackgroundColor('#00ff00',true); + }}> + <View style={styles.button}> + <Text>setBackgroundColor('#00ff00',true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setTranslucent(true); + StatusBar.setBackgroundColor('rgba(0, 0, 0, 0.4)',true); + }}> + <View style={styles.button}> + <Text>setTranslucent(true) and setBackgroundColor('rgba(0, 0, 0, 0.4)',true)</Text> + </View> + </TouchableHighlight> + <TouchableHighlight + style={styles.wrapper} + onPress={()=>{ + StatusBar.setTranslucent(false); + StatusBar.setBackgroundColor('black',true); + }}> + <View style={styles.button}> + <Text>setTranslucent(false) and setBackgroundColor('black',true)</Text> + </View> + </TouchableHighlight> + </View> + ); + }, +}); + +const examples =[{ + title:'StatusBar hidden', + render(){ + return <StatusBarHiddenExample />; + }, +},{ + title:'StatusBar style', + render(){ + return <StatusBarStyleExample />; + }, + platform:'ios', +},{ + title:'StatusBar network activity indicator', + render(){ + return <StatusBarNetworkActivityExample />; + }, + platform:'ios', +},{ + title:'StatusBar background color', + render(){ + return <StatusBarBackgroundColorExample />; + }, + platform:'android', +},{ + title:'StatusBar background color', + render(){ + return <StatusBarTranslucentExample />; + }, + platform:'android',},{ title:'StatusBar static API',render(){ - return <StatusBarStaticExample />; + return <StatusBarStaticIOSExample />;}, + platform:'ios', +},{ + title:'StatusBar static API', + render(){ + return <StatusBarStaticAndroidExample />; + }, + platform:'android', +},{ + title:'StatusBar dimensions', + render(){ + return( + <View> + <Text>Height:{StatusBar.currentHeight} pts</Text> + </View> + ); + }, + platform:'android',}]; +exports.examples = examples; + var styles = StyleSheet.create({ wrapper:{ borderRadius:5, @@ -317,7 +474,7 @@ exports.examples :8, fontWeight:'bold',} -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/statusbarios.html b/docs/statusbarios.html index 6f0e1ae50bd..e62c80a1113 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 #

Edit on GitHub

Deprecated. Use StatusBar instead.

Methods #

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

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

static setNetworkActivityIndicatorVisible(visible: boolean) #

Examples #

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

StatusBarIOS #

Edit on GitHub

Deprecated. Use StatusBar instead.

Methods #

static setStyle(style: 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 { @@ -99,7 +99,7 @@ exports.examples : '#eeeeee', padding: 10, }, -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/style.html b/docs/style.html index 9a0eae89772..b22a7f9217a 100644 --- a/docs/style.html +++ b/docs/style.html @@ -1,4 +1,4 @@ -Style – React Native | A framework for building native apps using React

Style #

Edit on GitHub

React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.

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

Style #

Edit on GitHub

React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.

Declare Styles #

The way to declare styles in React Native is the following:

var styles = StyleSheet.create({ base: { @@ -35,7 +35,7 @@ }); // ... in another file ... -<List style={styles.list} elementStyle={styles.listElement} />

Supported Properties #

You can checkout latest support of CSS Properties in following Links.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/stylesheet.html b/docs/stylesheet.html index 5ab49b58970..997a13618f8 100644 --- a/docs/stylesheet.html +++ b/docs/stylesheet.html @@ -1,4 +1,4 @@ -StyleSheet – React Native | A framework for building native apps using React

StyleSheet #

Edit on GitHub

A StyleSheet is an abstraction similar to CSS StyleSheets

Create a new StyleSheet:

var styles = StyleSheet.create({ +StyleSheet – React Native | A framework for building native apps using React

StyleSheet #

Edit on GitHub

A StyleSheet is an abstraction similar to CSS StyleSheets

Create a new StyleSheet:

var styles = StyleSheet.create({ container: { borderRadius: 4, borderWidth: 0.5, @@ -26,7 +26,7 @@ Example:

flatten: CallExpression #

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/switch.html b/docs/switch.html index 0faa657dc59..c423f1f0f80 100644 --- a/docs/switch.html +++ b/docs/switch.html @@ -1,4 +1,4 @@ -Switch – React Native | A framework for building native apps using React

Switch #

Edit on GitHub

Universal two-state toggle component.

Props #

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.

Examples #

Edit on GitHub
'use strict'; @@ -141,7 +141,7 @@ Default value is false.

< exports.title = '<Switch>'; exports.displayName = 'SwitchExample'; exports.description = 'Native boolean input'; -exports.examples = examples;

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/tabbarios-item.html b/docs/tabbarios-item.html index 59d5a51a189..1ac6f49504b 100644 --- a/docs/tabbarios-item.html +++ b/docs/tabbarios-item.html @@ -1,10 +1,10 @@ -TabBarIOS.Item – React Native | A framework for building native apps using React

TabBarIOS.Item #

Edit on GitHub

Props #

badge string, number #

Little red bubble that sits at the top right of the icon.

icon Image.propTypes.source #

A custom icon for the tab. It is ignored when a system icon is defined.

onPress function #

Callback when this tab is being selected, you should change the state of your +TabBarIOS.Item – React Native | A framework for building native apps using React

TabBarIOS.Item #

Edit on GitHub

Props #

badge string, number #

Little red bubble that sits at the top right of the icon.

icon Image.propTypes.source #

A custom icon for the tab. It is ignored when a system icon is defined.

onPress function #

Callback when this tab is being selected, you should change the state of your component to set selected={true}.

selected bool #

It specifies whether the children are visible or not. If you see a blank content, you probably forgot to add a selected one.

selectedIcon Image.propTypes.source #

A custom icon when the tab is selected. It is ignored when a system icon is defined. If left empty, the icon will be tinted in blue.

style View#style #

React style object.

systemIcon enum('bookmarks', 'contacts', 'downloads', 'favorites', 'featured', 'history', 'more', 'most-recent', 'most-viewed', 'recents', 'search', 'top-rated') #

Items comes with a few predefined system icons. Note that if you are using them, the title and selectedIcon will be overridden with the system ones.

title string #

Text that appears under the icon. It is ignored when a system icon -is defined.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/tabbarios.html b/docs/tabbarios.html index 8fa756d352a..ea356c65aef 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 GitHub

Props #

barTintColor color #

Background color of the tab bar

tintColor color #

Color of the currently selected tab icon

translucent bool #

A Boolean value that indicates whether the tab bar is translucent

Examples #

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

TabBarIOS #

Edit on GitHub

Props #

barTintColor color #

Background color of the tab bar

tintColor color #

Color of the currently selected tab icon

translucent bool #

A Boolean value that indicates whether the tab bar is translucent

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); var { @@ -92,7 +92,7 @@ }, }); -module.exports = TabBarExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/testing.html b/docs/testing.html index 1559e05a865..d6e74eb0def 100644 --- a/docs/testing.html +++ b/docs/testing.html @@ -1,4 +1,4 @@ -Testing – React Native | A framework for building native apps using React

Testing #

Edit on GitHub

Running Tests and Contributing #

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR.

We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!

Jest Tests #

Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with

npm test

from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

Note: In order to run your own tests, you will have to first follow the Getting Started instructions on the Jest page and then include the jest objects below in package.json so that the scripts are pre-processed before execution.

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

Testing #

Edit on GitHub

Running Tests and Contributing #

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR.

We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!

Jest Tests #

Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with

npm test

from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

Note: In order to run your own tests, you will have to first follow the Getting Started instructions on the Jest page and then include the jest objects below in package.json so that the scripts are pre-processed before execution.

... "scripts": { ... "test": "jest" @@ -19,7 +19,7 @@ "source-map" ] }, -...

Note: you may have to install/upgrade/link Node.js and other parts of your environment in order for the tests to run correctly. Check out the latest setup in .travis.yml

Integration Tests (iOS only) #

React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS as NativeModules.TestModule. The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria. See IntegrationTestHarnessTest.js, UIExplorerIntegrationTests.m, and IntegrationTestsApp.js for example usage and integration points.

You can run integration tests locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode.

Snapshot Tests (iOS only) #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshot reference image. To do this, simply change to _runner.recordMode = YES; in UIExplorer/UIExplorerSnapshotTests.m, re-run the failing tests, then flip record back to NO and submit/update your PR and wait to see if the Travis build passes.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/text.html b/docs/text.html index c8688500571..e253aacd057 100644 --- a/docs/text.html +++ b/docs/text.html @@ -1,4 +1,4 @@ -Text – React Native | A framework for building native apps using React

Text #

Edit on GitHub

A React component for displaying text which supports nesting, +Text – React Native | A framework for building native apps using React

Text #

Edit on GitHub

A React component for displaying text which supports nesting, styling, and touch handling. In the following example, the nested title and body text will inherit the fontFamily from styles.baseText, but the title provides its own additional styles. The title and body will stack on top of @@ -74,7 +74,7 @@ html { <Text style={{color: 'red'}}> and red </Text> -</Text>

We believe that this more constrained way to style text will yield better apps:

  • (Developer) React components are designed with strong isolation in mind: You should be able to drop a component anywhere in your application, trusting that as long as the props are the same, it will look and behave the same way. Text properties that could inherit from outside of the props would break this isolation.

  • (Implementor) The implementation of React Native is also simplified. We do not need to have a fontFamily field on every single element, and we do not need to potentially traverse the tree up to the root every time we display a text node. The style inheritance is only encoded inside of the native Text component and doesn't leak to other components or the system itself.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/textinput.html b/docs/textinput.html index a4cf4d5d5e5..05987514023 100644 --- a/docs/textinput.html +++ b/docs/textinput.html @@ -1,4 +1,4 @@ -TextInput – React Native | A framework for building native apps using React

TextInput #

Edit on GitHub

A foundational component for inputting text into the app via a +TextInput – React Native | A framework for building native apps using React

TextInput #

Edit on GitHub

A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto-correction, auto-capitalization, placeholder text, and different keyboard types, such as a numeric keypad.

The simplest use case is to plop down a TextInput and subscribe to the @@ -8,7 +8,13 @@ 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}:

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

Note that some props are only available with multiline={true/false}. +Additionally, border styles that apply to only one side of the element +(e.g., borderBottomColor, borderLeftWidth, etc.) will not be applied if +multiline=false. To achieve the same effect, you can wrap your TextInput +in a View:

<View style={{ borderBottomColor: '#000000', borderBottomWidth: 1, }}> + <TextInput {...props} /> + </View>

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.

blurOnSubmit bool #

If true, the text field will blur when submitted. The default value is true for single-line fields and false for multiline fields. Note that for multiline fields, setting blurOnSubmit @@ -34,7 +40,7 @@ true to be able to fill the lines.

ioskeyboardAppearance enum('default', 'light', 'dark') #

Determines the color of the keyboard.

iosonKeyPress function #

Callback that is called when a key is pressed. Pressed key value is passed as an argument to the callback handler. Fires before onChange callbacks.

iosreturnKeyType enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') #

Determines how the return key should look.

iosselectTextOnFocus bool #

If true, all text will automatically be selected on focus

iosselectionState DocumentSelectionState #

See DocumentSelectionState.js, some state that is responsible for -maintaining selection information for a document

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/timepickerandroid.html b/docs/timepickerandroid.html index dc2b3ad2f39..4f628b72da3 100644 --- a/docs/timepickerandroid.html +++ b/docs/timepickerandroid.html @@ -1,4 +1,4 @@ -TimePickerAndroid – React Native | A framework for building native apps using React

TimePickerAndroid #

Edit on GitHub

Opens the standard Android time picker dialog.

Example #

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

TimePickerAndroid #

Edit on GitHub

Opens the standard Android time picker dialog.

Example #

try { const {action, hour, minute} = await TimePickerAndroid.open({ hour: 14, minute: 0, @@ -114,7 +114,7 @@ being undefined. Always check whether the action b }, }); -module.exports = TimePickerAndroidExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/timers.html b/docs/timers.html index bf329662f6a..f32c4913818 100644 --- a/docs/timers.html +++ b/docs/timers.html @@ -1,4 +1,4 @@ -Timers – React Native | A framework for building native apps using React

Timers #

Edit on GitHub

Timers are an important part of an application and React Native implements the browser timers.

Timers #

  • setTimeout, clearTimeout
  • setInterval, clearInterval
  • setImmediate, clearImmediate
  • requestAnimationFrame, cancelAnimationFrame

requestAnimationFrame(fn) is not the same as setTimeout(fn, 0) - the former will fire after all the frame has flushed, whereas the latter will fire as quickly as possible (over 1000x per second on a iPhone 5S).

setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.

The Promise implementation uses setImmediate as its asynchronicity primitive.

InteractionManager #

One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.

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

InteractionManager.runAfterInteractions(() => { +Timers – React Native | A framework for building native apps using React

Timers #

Edit on GitHub

Timers are an important part of an application and React Native implements the browser timers.

Timers #

  • setTimeout, clearTimeout
  • setInterval, clearInterval
  • setImmediate, clearImmediate
  • requestAnimationFrame, cancelAnimationFrame

requestAnimationFrame(fn) is not the same as setTimeout(fn, 0) - the former will fire after all the frame has flushed, whereas the latter will fire as quickly as possible (over 1000x per second on a iPhone 5S).

setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.

The Promise implementation uses setImmediate as its asynchronicity primitive.

InteractionManager #

One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.

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

InteractionManager.runAfterInteractions(() => { // ...long-running synchronous task... });

Compare this to other scheduling alternatives:

  • requestAnimationFrame(): for code that animates a view over time.
  • setImmediate/setTimeout/setInterval(): run code later, note this may delay animations.
  • runAfterInteractions(): run code later, without delaying active animations.

The touch handling system considers one or more active touches to be an 'interaction' and will delay runAfterInteractions() callbacks until all touches have ended or been cancelled.

InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

var handle = InteractionManager.createInteractionHandle(); // run animation... (`runAfterInteractions` tasks are queued) @@ -14,7 +14,7 @@ 500 ); } -});

We strongly discourage using the global setTimeout(...) and recommend instead that you use this.setTimeout(...) provided by react-timer-mixin. This will eliminate a lot of hard work tracking down bugs, such as crashes caused by timeouts firing after a component has been unmounted.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/toastandroid.html b/docs/toastandroid.html index b8a61a7a747..27e48c8216e 100644 --- a/docs/toastandroid.html +++ b/docs/toastandroid.html @@ -1,4 +1,4 @@ -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' +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'); @@ -51,7 +51,7 @@ which takes the following parameters:

  1. String message: A string with t }, }); -module.exports = ToastExample;
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/toolbarandroid.html b/docs/toolbarandroid.html index 45cdf28cef3..b847b943854 100644 --- a/docs/toolbarandroid.html +++ b/docs/toolbarandroid.html @@ -1,4 +1,4 @@ -ToolbarAndroid – React Native | A framework for building native apps using React

ToolbarAndroid #

Edit on GitHub

React component that wraps the Android-only Toolbar widget. A Toolbar can display a logo, +ToolbarAndroid – React Native | A framework for building native apps using React

ToolbarAndroid #

Edit on GitHub

React component that wraps the Android-only Toolbar widget. A Toolbar can display a logo, navigation icon (e.g. hamburger menu), a title & subtitle and a list of actions. The title and subtitle are expanded so the logo and navigation icons are displayed on the left, title and subtitle in the middle and the actions on the right.

If the toolbar has an only child, it will be displayed between the title and actions.

Although the Toolbar supports remote images for the logo, navigation and action icons, this @@ -18,7 +18,7 @@ onActionSelected: if (position === 0) { // index of 'Settings' showSettings(); } -}

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

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 @@ -148,7 +148,7 @@ In addition to this property you need to add

android:supportsRtl="t }, }); -module.exports = ToolbarAndroidExample;

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/touchablehighlight.html b/docs/touchablehighlight.html index 7f01dc6c6a0..ebbfb0cff88 100644 --- a/docs/touchablehighlight.html +++ b/docs/touchablehighlight.html @@ -1,4 +1,4 @@ -TouchableHighlight – React Native | A framework for building native apps using React

TouchableHighlight #

Edit on GitHub

A wrapper for making views respond properly to touches. +TouchableHighlight – React Native | A framework for building native apps using React

TouchableHighlight #

Edit on GitHub

A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, which allows the underlay color to show through, darkening or tinting the view. The underlay comes from adding a view to the view hierarchy, which can sometimes @@ -14,7 +14,7 @@ backgroundColor of the wrapped view isn't explicitly set to an opaque color ); },

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.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/touchablenativefeedback.html b/docs/touchablenativefeedback.html index f4388ac1505..a1cd383b94d 100644 --- a/docs/touchablenativefeedback.html +++ b/docs/touchablenativefeedback.html @@ -1,4 +1,4 @@ -TouchableNativeFeedback – React Native | A framework for building native apps using React

TouchableNativeFeedback #

Edit on GitHub

A wrapper for making views respond properly to touches (Android only). +TouchableNativeFeedback – React Native | A framework for building native apps using React

TouchableNativeFeedback #

Edit on GitHub

A wrapper for making views respond properly to touches (Android only). On Android this component uses native state drawable to display touch feedback. At the moment it only supports having a single View instance as a child node, as it's implemented by replacing that View with another instance @@ -26,7 +26,7 @@ object that represents ripple drawable with specified color (as a string). If property borderless evaluates to true the ripple will render outside of the view bounds (see native actionbar buttons as an example of that behavior). This background type is available on Android -API level 21+

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/touchableopacity.html b/docs/touchableopacity.html index 0efd5153b67..de706d0b141 100644 --- a/docs/touchableopacity.html +++ b/docs/touchableopacity.html @@ -1,4 +1,4 @@ -TouchableOpacity – React Native | A framework for building native apps using React

TouchableOpacity #

Edit on GitHub

A wrapper for making views respond properly to touches. +TouchableOpacity – React Native | A framework for building native apps using React

TouchableOpacity #

Edit on GitHub

A wrapper for making views respond properly to touches. On press down, the opacity of the wrapped view is decreased, dimming it. This is done without actually changing the view hierarchy, and in general is easy to add to an app without weird side-effects.

Example:

renderButton: function() { @@ -11,7 +11,7 @@ easy to add to an app without weird side-effects.

Example:

/TouchableOpacity> ); },

Props #

activeOpacity number #

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

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/touchablewithoutfeedback.html b/docs/touchablewithoutfeedback.html index 15924265e23..5f0b4cc9b02 100644 --- a/docs/touchablewithoutfeedback.html +++ b/docs/touchablewithoutfeedback.html @@ -1,6 +1,6 @@ -TouchableWithoutFeedback – React Native | A framework for building native apps using React

TouchableWithoutFeedback #

Edit on GitHub

Do not use unless you have a very good reason. All the elements that +TouchableWithoutFeedback – React Native | A framework for building native apps using React

TouchableWithoutFeedback #

Edit on GitHub

Do not use unless you have a very good reason. All the elements that respond to press should have a visual feedback when touched. This is -one of the primary reason a "web" app doesn't feel "native".

NOTE: TouchableWithoutFeedback supports only one child

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

Props #

accessibilityComponentType View.AccessibilityComponentType #

accessibilityTraits View.AccessibilityTraits, [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.

disabled bool #

If true, disable all interactions for this component.

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

This defines how far your touch can start away from the button. This is +one of the primary reason a "web" app doesn't feel "native".

NOTE: TouchableWithoutFeedback supports only one child

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

Props #

accessibilityComponentType View.AccessibilityComponentType #

accessibilityTraits View.AccessibilityTraits, [object Object] #

accessible bool #

delayLongPress number #

Delay in ms, from onPressIn, before onLongPress is called.

delayPressIn number #

Delay in ms, from the start of the touch, before onPressIn is called.

delayPressOut number #

Delay in ms, from the release of the touch, before onPressOut is called.

disabled bool #

If true, disable all interactions for this component.

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

This defines how far your touch can start away from the button. This is added to pressRetentionOffset when moving off of the button. NOTE The touch area never extends past the parent view bounds and the Z-index @@ -10,7 +10,7 @@ that steals the responder lock).

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/transforms.html b/docs/transforms.html index e94236cb649..61fa0940382 100644 --- a/docs/transforms.html +++ b/docs/transforms.html @@ -1,4 +1,4 @@ -Transforms – React Native | A framework for building native apps using React

Transforms #

Edit on GitHub

Props #

transform [{perspective: number}, {rotate: string}, {rotateX: string}, {rotateY: string}, {rotateZ: string}, {scale: number}, {scaleX: number}, {scaleY: number}, {translateX: number}, {translateY: number}, {skewX: string}, {skewY: string}] #

transformMatrix TransformMatrixPropType #

© 2016 Facebook Inc.

Transforms #

Edit on GitHub

Props #

transform [{perspective: number}, {rotate: string}, {rotateX: string}, {rotateY: string}, {rotateZ: string}, {scale: number}, {scaleX: number}, {scaleY: number}, {translateX: number}, {translateY: number}, {skewX: string}, {skewY: string}] #

transformMatrix TransformMatrixPropType #

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html index 15ad87c9600..b595961fc7e 100644 --- a/docs/troubleshooting.html +++ b/docs/troubleshooting.html @@ -1,4 +1,4 @@ -Troubleshooting – React Native | A framework for building native apps using React

Troubleshooting #

Edit on GitHub

Cmd-R does not reload the simulator #

Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.

Keyboard Menu

If you are using a non-QWERTY/AZERTY keyboard layout you can use the Hardware > Shake Gesture to bring up the dev menu and click "Refresh"

Port already in use red-screen #

red-screen

Something is probably already running on port 8081. You can either kill it or try to change which port the packager is listening to.

Kill process on port 8081 #

$ sudo lsof -n -i4TCP:8081 | grep LISTEN

then

$ kill -9 <cma process id>

Change the port in Xcode #

Edit AppDelegate.m to use a different port.

// OPTION 1 +Troubleshooting – React Native | A framework for building native apps using React

Troubleshooting #

Edit on GitHub

Cmd-R does not reload the simulator #

Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.

Keyboard Menu

If you are using a non-QWERTY/AZERTY keyboard layout you can use the Hardware > Shake Gesture to bring up the dev menu and click "Refresh"

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 @@ -13,7 +13,7 @@ sudo chown -R $USER 'RCTNetwork', 'RCTWebSocket', ]

Next, make sure you have run pod install and that a Pods/ directory has been created in your project with React installed. CocoaPods will instruct you to use the generated .xcworkspace file henceforth to be able to use these installed dependencies.

If you are adding React manually, make sure you have included all the relevant dependencies, like RCTText.xcodeproj, RCTImage.xcodeproj depending on the ones you are using. Next, the binaries built by these dependencies have to be linked to your app binary. Use the Linked Frameworks and Binaries section in the Xcode project settings. More detailed steps are here: Linking Libraries.

Argument list too long: recursive header expansion failed #

In the project's build settings, User Search Header Paths and Header Search Paths are two configs that specify where Xcode should look for #import header files specified in the code. For Pods, CocoaPods uses a default array of specific folders to look in. Verify that this particular config is not overwritten, and that none of the folders configured are too large. If one of the folders is a large folder, Xcode will attempt to recursively search the entire directory and throw above error at some point.

To revert the User Search Header Paths and Header Search Paths build settings to their defaults set by CocoaPods - select the entry in the Build Settings panel, and hit delete. It will remove the custom override and return to the CocoaPod defaults.

Unable to connect to development server #

iOS #

Ensure that you are on the same WiFi network as your computer. If you're using a cell data plan, your phone can't access your computer's local IP address.

Android #

You need to run adb reverse tcp:8081 tcp:8081 to forward requests from the device to your computer. This works only on Android 5.0 and newer.

Module that uses WebSocket (such as Firebase) throws an exception #

React Native implements a polyfill for WebSockets. These polyfills are initialized as part of the react-native module that you include in your application through import React from 'react-native'. If you load another module that requires WebSockets, be sure to load/require it after react-native.

So:

import React from 'react-native'; -import Firebase from 'firebase';

Requiring firebase before react-native will result in a 'No transports available' redbox.

Discovered thanks to issue #3645. If you're curious, the polyfills are set up in InitializeJavaScriptAppEngine.js.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/tutorial.html b/docs/tutorial.html index 352c797ac39..8afda4639e6 100644 --- a/docs/tutorial.html +++ b/docs/tutorial.html @@ -1,4 +1,4 @@ -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.

Overview #

In this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.

Starting the app on iOS #

Open this new project (AwesomeProject/ios/AwesomeProject.xcodeproj) in Xcode and simply build and run it with ⌘+R. Doing so will also start a Node server which enables live code reloading. With this you can see your changes by pressing ⌘+R in the simulator rather than recompiling in Xcode.

Starting the app on Android #

In your terminal navigate into the AwesomeProject and run:

react-native run-android

This will install the generated app on your emulator or device, as well as start the Node server which enables live code reloading. To see your changes you have to open the rage-shake-menu (either shake the device or press the menu button on devices, press F2 or Page Up for emulator, ⌘+M for Genymotion), and then press Reload JS.

Hello World #

react-native init will generate an app with the name of your project, in this case AwesomeProject. This is a simple hello world app. For iOS, you can edit index.ios.js to make changes to the app and then press ⌘+R in the simulator to see the changes. For Android, you can edit index.android.js to make changes to the app and press Reload JS from the rage shake menu to see the changes.

Mocking data #

Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the imports, but feel free to add the following constant wherever you like. In index.ios.js or index.android.js :

var MOCKED_MOVIES_DATA = [ +Tutorial – React Native | A framework for building native apps using React

Tutorial #

Edit on GitHub

Preface #

This tutorial aims to get you up to speed with writing iOS and Android apps using React Native. If you're wondering what React Native is and why Facebook built it, this blog post explains that.

We assume you have experience writing applications with React. If not, you can learn about it on the React website.

Setup #

React Native requires the basic setup explained at React Native Getting Started.

After installing these dependencies there are two simple commands to get a React Native project all set up for development.

  1. npm install -g react-native-cli

    react-native-cli is a command line interface that does the rest of the set up. It’s installable via npm. This will install react-native as a command in your terminal. You only ever need to do this once.

  2. react-native init AwesomeProject

    This command fetches the React Native source code and dependencies and then creates a new Xcode project in AwesomeProject/iOS/AwesomeProject.xcodeproj and a gradle project in AwesomeProject/android/app.

Overview #

In this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.

Starting the app on iOS #

Open this new project (AwesomeProject/ios/AwesomeProject.xcodeproj) in Xcode and simply build and run it with ⌘+R. Doing so will also start a Node server which enables live code reloading. With this you can see your changes by pressing ⌘+R in the simulator rather than recompiling in Xcode.

Starting the app on Android #

In your terminal navigate into the AwesomeProject and run:

react-native run-android

This will install the generated app on your emulator or device, as well as start the Node server which enables live code reloading. To see your changes you have to open the rage-shake-menu (either shake the device or press the menu button on devices, press F2 or Page Up for emulator, ⌘+M for Genymotion), and then press Reload JS.

Hello World #

react-native init will generate an app with the name of your project, in this case AwesomeProject. This is a simple hello world app. For iOS, you can edit index.ios.js to make changes to the app and then press ⌘+R in the simulator to see the changes. For Android, you can edit index.android.js to make changes to the app and press Reload JS from the rage shake menu to see the changes.

Mocking data #

Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the imports, but feel free to add the following constant wherever you like. In index.ios.js or index.android.js :

var MOCKED_MOVIES_DATA = [ {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}}, ];

Render a movie #

We're going to render the title, year, and thumbnail for the movie. Since thumbnail is an Image component in React Native, add Image to the list of React imports below.

import React, { AppRegistry, @@ -293,7 +293,7 @@ class AwesomeProject extends }, }); -AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/upgrading.html b/docs/upgrading.html index 938f6ca525e..8ac35c90a08 100644 --- a/docs/upgrading.html +++ b/docs/upgrading.html @@ -1,4 +1,4 @@ -Upgrading – React Native | A framework for building native apps using React

Upgrading #

Edit on GitHub

Upgrading to new versions of React Native will give you access to more APIs, views, developer tools +Upgrading – React Native | A framework for building native apps using React

Upgrading #

Edit on GitHub

Upgrading to new versions of React Native will give you access to more APIs, views, developer tools and other goodies. Because React Native projects are essentially made up of an Android project, an iOS project and a JavaScript project, all combined under an npm package, upgrading can be rather tricky. But we try to make it easy for you. Here's what you need to do to upgrade from an older @@ -6,7 +6,7 @@ version of React Native:

$ react-native upgrade

This will check your files against the latest template and perform the following:

Manual Upgrades #

Xcode project format is pretty complex and sometimes it's tricky to upgrade and merge new changes.

From 0.13 to 0.14 #

The major change in this version happened to the CLI (see changelog) and static images (see docs). To use the new asset system in existing Xcode project, do the following:

Add new "Run Script" step to your project's build phases:

Set the script to

../node_modules/react-native/packager/react-native-xcode.sh

Move main.jsbundle to Trash (it will be generated automatically by Xcode using the script above)

If you installed Node via nvm, you might experience "react-native: command not found". See issues/3974 for workaround and pull/4015 for the fix.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/vibration.html b/docs/vibration.html index 0a9d301b46a..8c1a7a19e32 100644 --- a/docs/vibration.html +++ b/docs/vibration.html @@ -1,4 +1,4 @@ -Vibration – React Native | A framework for building native apps using React

Vibration #

Edit on GitHub

The Vibration API is exposed at Vibration.vibrate(). +Vibration – React Native | A framework for building native apps using React

Vibration #

Edit on GitHub

The Vibration API is exposed at Vibration.vibrate(). The vibration is asynchronous so this method will return immediately.

There will be no effect on devices that do not support Vibration, eg. the simulator.

Note for android add <uses-permission android:name="android.permission.VIBRATE"/> to AndroidManifest.xml

Vibration patterns are currently unsupported.

Methods #

static vibrate(duration: number) #

Examples #

Edit on GitHub
'use strict'; @@ -38,7 +38,7 @@ exports.examples : '#eeeeee', padding: 10, }, -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/vibrationios.html b/docs/vibrationios.html index 51b66ac83e1..aa50e3a3cb4 100644 --- a/docs/vibrationios.html +++ b/docs/vibrationios.html @@ -1,4 +1,4 @@ -VibrationIOS – React Native | A framework for building native apps using React

VibrationIOS #

Edit on GitHub

NOTE: VibrationIOS is being deprecated. Use Vibration instead.

The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this +VibrationIOS – React Native | A framework for building native apps using React

VibrationIOS #

Edit on GitHub

NOTE: VibrationIOS is being deprecated. Use Vibration instead.

The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this function will trigger a one second vibration. The vibration is asynchronous so this method will return immediately.

There will be no effect on devices that do not support Vibration, eg. the iOS simulator.

Vibration patterns are currently unsupported.

Methods #

static vibrate() #

@deprecated

Examples #

Edit on GitHub
'use strict'; @@ -39,7 +39,7 @@ exports.examples : '#eeeeee', padding: 10, }, -});
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/videos.html b/docs/videos.html index c3ff0e041cf..1c7281e47f4 100644 --- a/docs/videos.html +++ b/docs/videos.html @@ -1,4 +1,4 @@ -Videos – React Native | A framework for building native apps using React

Videos #

Edit on GitHub

React.js Conf 2016 #

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

Videos #

Edit on GitHub

React.js Conf 2016 #

@@ -46,7 +46,7 @@ This player is only available in HTML5 enabled browsers. Please update your brow download the episode

-
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/view.html b/docs/view.html index 247a57b38fc..8700f4e1eb9 100644 --- a/docs/view.html +++ b/docs/view.html @@ -1,4 +1,4 @@ -View – React Native | A framework for building native apps using React

View #

Edit on GitHub

The most fundamental component for building UI, View is a +View – React Native | A framework for building native apps using React

View #

Edit on GitHub

The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type. View maps directly to the native @@ -26,22 +26,21 @@ the new layout may not yet be reflected on the screen at the time the event is received, especially if a layout animation is in progress.

onMagicTap function #

When accessible is true, the system will invoke this function when the user performs the magic tap gesture.

onMoveShouldSetResponder function #

onMoveShouldSetResponderCapture function #

onResponderGrant function #

For most touch interactions, you'll simply want to wrap your component in TouchableHighlight or TouchableOpacity. Check out Touchable.js, -ScrollResponder.js and ResponderEventPlugin.js for more discussion.

onResponderMove function #

onResponderReject function #

onResponderRelease function #

onResponderTerminate function #

onResponderTerminationRequest function #

onStartShouldSetResponder function #

onStartShouldSetResponderCapture function #

pointerEvents enum('box-none', 'none', 'box-only', 'auto') #

In the absence of auto property, none is much like CSS's none -value. box-none is as if you had applied the CSS class:

.box-none { - pointer-events: none; +ScrollResponder.js and ResponderEventPlugin.js for more discussion.

onResponderMove function #

onResponderReject function #

onResponderRelease function #

onResponderTerminate function #

onResponderTerminationRequest function #

onStartShouldSetResponder function #

onStartShouldSetResponderCapture function #

pointerEvents enum('box-none', 'none', 'box-only', 'auto') #

Controls whether the View can be the target of touch events.

  • 'auto': The View can be the target of touch events.
  • 'none': The View is never the target of touch events.
  • 'box-none': The View is never the target of touch events but it's +subviews can be. It behaves like if the following classes +in CSS:
    .box-none { + pointer-events: none; } .box-none * { - pointer-events: all; -}

    box-only is the equivalent of

    .box-only { - pointer-events: all; + pointer-events: all; +}
  • 'box-only': The view can be the target of touch events but it's +subviews cannot be. It behaves like if the following classes +in CSS:
    .box-only { + pointer-events: all; } .box-only * { - pointer-events: none; -}

    But since pointerEvents does not affect layout/appearance, and we are -already deviating from the spec by adding additional modes, we opt to not -include pointerEvents on style. On some platforms, we would need to -implement it as a className anyways. Using style or not is an -implementation detail of the platform.

removeClippedSubviews bool #

This is a special performance property exposed by RCTView and is useful + pointer-events: none; +}

removeClippedSubviews bool #

This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews, most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound. The @@ -89,7 +88,7 @@ view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the -interaction/animation.

iosaccessibilityTraits AccessibilityTraits, [AccessibilityTraits] #

Provides additional traits to screen reader. By default no traits are +interaction/animation.

iosaccessibilityTraits AccessibilityTraits, [object Object] #

Provides additional traits to screen reader. By default no traits are provided unless specified otherwise in element

iosshouldRasterizeIOS bool #

Whether this view should be rendered as a bitmap before compositing.

On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children; for example, when translating the position of a static view, rasterization allows the @@ -271,7 +270,7 @@ exports.examples ); }, }, -];

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/viewpagerandroid.html b/docs/viewpagerandroid.html index 32fd489faef..8f7128276c2 100644 --- a/docs/viewpagerandroid.html +++ b/docs/viewpagerandroid.html @@ -1,4 +1,4 @@ -ViewPagerAndroid – React Native | A framework for building native apps using React

ViewPagerAndroid #

Edit on GitHub

Container that allows to flip left and right between child views. Each +ViewPagerAndroid – React Native | A framework for building native apps using React

ViewPagerAndroid #

Edit on GitHub

Container that allows to flip left and right between child views. Each child view of the ViewPagerAndroid will be treated as a separate page and will be stretched to fill the ViewPagerAndroid.

It is important all children are <View>s and not composite components. You can set style properties like padding or backgroundColor for each @@ -290,7 +290,7 @@ import type { ViewPagerScrollState }, }); -module.exports = ViewPagerAndroidExample;

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/docs/webview.html b/docs/webview.html index ba5e68ae6fd..c2b1f8f13fa 100644 --- a/docs/webview.html +++ b/docs/webview.html @@ -1,4 +1,5 @@ -WebView – React Native | A framework for building native apps using React

WebView #

Edit on GitHub

Renders a native WebView.

Props #

automaticallyAdjustContentInsets bool #

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

html string #

Deprecated

Use the source prop instead.

injectedJavaScript string #

Sets the JS to be injected when the webpage loads.

onError function #

Invoked when load fails

onLoad function #

Invoked when load finish

onLoadEnd function #

Invoked when load either succeeds or fails

onLoadStart function #

Invoked on load start

onNavigationStateChange function #

renderError function #

Function that returns a view to show if there's an error.

renderLoading function #

Function that returns a loading indicator.

scalesPageToFit bool #

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

source {uri: string, method: string, headers: object, body: string}, {html: string, baseUrl: string}, number #

Loads static html or a uri (with optional headers) in the WebView.

startInLoadingState bool #

url string #

Deprecated

Use the source prop instead.

androiddomStorageEnabled bool #

Used on Android only, controls whether DOM Storage is enabled or not

androidjavaScriptEnabled bool #

Used on Android only, JS is enabled by default for WebView on iOS

iosallowsInlineMediaPlayback bool #

Determines whether HTML5 videos play inline or use the native full-screen +WebView – React Native | A framework for building native apps using React

WebView #

Edit on GitHub

Renders a native WebView.

Props #

automaticallyAdjustContentInsets bool #

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

html string #

Deprecated

Use the source prop instead.

injectedJavaScript string #

Sets the JS to be injected when the webpage loads.

mediaPlaybackRequiresUserAction bool #

Determines whether HTML5 audio & videos require the user to tap before they can +start playing. The default value is false.

onError function #

Invoked when load fails

onLoad function #

Invoked when load finish

onLoadEnd function #

Invoked when load either succeeds or fails

onLoadStart function #

Invoked on load start

onNavigationStateChange function #

renderError function #

Function that returns a view to show if there's an error.

renderLoading function #

Function that returns a loading indicator.

scalesPageToFit bool #

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

source {uri: string, method: string, headers: object, body: string}, {html: string, baseUrl: string}, number #

Loads static html or a uri (with optional headers) in the WebView.

startInLoadingState bool #

url string #

Deprecated

Use the source prop instead.

androiddomStorageEnabled bool #

Used on Android only, controls whether DOM Storage is enabled or not

androidjavaScriptEnabled bool #

Used on Android only, JS is enabled by default for WebView on iOS

iosallowsInlineMediaPlayback bool #

Determines whether HTML5 videos play inline or use the native full-screen controller. default value false NOTE : "In order for video to play inline, not only does this @@ -8,8 +9,8 @@ decelerates after the user lifts their finger. You may also use string shortcuts "normal" and "fast" which match the underlying iOS settings 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 + - normal: 0.998 + - fast: 0.99 (the default for iOS WebView)

iosonShouldStartLoadWithRequest function #

Allows custom handling of any webview requests by a JS handler. Return true or false from this method to continue loading the request.

iosscrollEnabled bool #

Examples #

Edit on GitHub
'use strict'; var React = require('react-native'); @@ -387,7 +388,7 @@ exports.examples ); } } -];
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/index.html b/index.html index 56071797c55..b167b0eecc9 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,13 @@ -React Native | A framework for building native apps using React
React Native
A framework for building native apps using React

React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

Native Components

With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

// iOS +React Native | A framework for building native apps using React
React Native
A framework for building native apps using React

React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

Native Components

With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

// iOS -var React = require('react-native'); -var { TabBarIOS, NavigatorIOS } = React; +import React, { + Component, + TabBarIOS, + NavigatorIOS +} from 'react-native'; -var App = React.createClass({ - render: function() { +class App extends Component { + render() { return ( <TabBarIOS> <TabBarIOS.Item title="React Native" selected={true}> @@ -12,28 +15,36 @@ </TabBarIOS.Item> </TabBarIOS> ); - }, -});
// Android + } +}
// Android -var React = require('react-native'); -var { DrawerLayoutAndroid, ProgressBarAndroid, Text } = React; +import React, { + Component, + DrawerLayoutAndroid, + ProgressBarAndroid, + Text +} from 'react-native'; -var App = React.createClass({ - render: function() { +class App extends Component { + render() { return ( <DrawerLayoutAndroid renderNavigationView={() => <Text>React Native</Text>}> <ProgressBarAndroid /> </DrawerLayoutAndroid> ); - }, -});

Asynchronous Execution

All operations between the JavaScript application code and the native platform are performed asynchronously, and the native modules can also make use of additional threads as well. This means we can decode images off of the main thread, save to disk in the background, measure text and compute layouts without blocking the UI, and more. As a result, React Native apps are naturally fluid and responsive. The communication is also fully serializable, which allows us to leverage Chrome Developer Tools to debug the JavaScript while running the complete app, either in the simulator or on a physical device.

See Debugging.

Touch Handling

React Native implements a powerful system to negotiate touches in complex view hierarchies and provides high level components such as TouchableHighlight that integrate properly with scroll views and other elements without any additional configuration.

// iOS & Android + } +}

Asynchronous Execution

All operations between the JavaScript application code and the native platform are performed asynchronously, and the native modules can also make use of additional threads as well. This means we can decode images off of the main thread, save to disk in the background, measure text and compute layouts without blocking the UI, and more. As a result, React Native apps are naturally fluid and responsive. The communication is also fully serializable, which allows us to leverage Chrome Developer Tools to debug the JavaScript while running the complete app, either in the simulator or on a physical device.

See Debugging.

Touch Handling

React Native implements a powerful system to negotiate touches in complex view hierarchies and provides high level components such as TouchableHighlight that integrate properly with scroll views and other elements without any additional configuration.

// iOS & Android -var React = require('react-native'); -var { ScrollView, TouchableHighlight, Text } = React; +import React, { + Component, + ScrollView, + TouchableHighlight, + Text +} from 'react-native'; -var TouchDemo = React.createClass({ - render: function() { +class TouchDemo extends Component { + render() { return ( <ScrollView> <TouchableHighlight onPress={() => console.log('pressed')}> @@ -41,14 +52,19 @@ </TouchableHighlight> </ScrollView> ); - }, -});

Flexbox and Styling

Laying out views should be easy, which is why we brought the flexbox layout model from the web to React Native. Flexbox makes it simple to build the most common UI layouts, such as stacked and nested boxes with margin and padding. React Native also supports common web styles, such as fontWeight, and the StyleSheet abstraction provides an optimized mechanism to declare all your styles and layout right along with the components that use them and apply them inline.

// iOS & Android + } +}

Flexbox and Styling

Laying out views should be easy, which is why we brought the flexbox layout model from the web to React Native. Flexbox makes it simple to build the most common UI layouts, such as stacked and nested boxes with margin and padding. React Native also supports common web styles, such as fontWeight, and the StyleSheet abstraction provides an optimized mechanism to declare all your styles and layout right along with the components that use them and apply them inline.

// iOS & Android -var React = require('react-native'); -var { Image, StyleSheet, Text, View } = React; +var React, { + Component, + Image, + StyleSheet, + Text, + View +} from 'react-native'; -var ReactNative = React.createClass({ - render: function() { +class ReactNative extends Component { + render() { return ( <View style={styles.row}> <Image @@ -65,37 +81,40 @@ </View> </View> ); - }, -}); + } +} var styles = StyleSheet.create({ row: { flexDirection: 'row', margin: 40 }, image: { width: 40, height: 40, marginRight: 10 }, text: { flex: 1, justifyContent: 'center'}, title: { fontSize: 11, fontWeight: 'bold' }, subtitle: { fontSize: 10 }, -});

Polyfills

React Native is focused on changing the way view code is written. For the rest, we look to the web for universal standards and polyfill those APIs where appropriate. You can use npm to install JavaScript libraries that work on top of the functionality baked into React Native, such as XMLHttpRequest, window.requestAnimationFrame, and navigator.geolocation. We are working on expanding the available APIs, and are excited for the Open Source community to contribute as well.

// iOS (Android support for geolocation coming) +});

Polyfills

React Native is focused on changing the way view code is written. For the rest, we look to the web for universal standards and polyfill those APIs where appropriate. You can use npm to install JavaScript libraries that work on top of the functionality baked into React Native, such as XMLHttpRequest, window.requestAnimationFrame, and navigator.geolocation. We are working on expanding the available APIs, and are excited for the Open Source community to contribute as well.

// iOS & Android -var React = require('react-native'); -var { Text } = React; +import React, { + Component, + Text +} from 'react-native'; -var GeoInfo = React.createClass({ - getInitialState: function() { - return { position: 'unknown' }; +class GeoInfo extends Component { + constructor(props) { + super(props); + this.state = { position: 'unknown' }; }, - componentDidMount: function() { + componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => this.setState({position}), (error) => console.error(error) ); - }, - render: function() { + } + render() { return ( <Text> Position: {JSON.stringify(this.state.position)} </Text> ); - }, -});

Extensibility

It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you've already built, and can import and use your favorite native libraries.

Creating iOS modules

To create a simple iOS module, create a new class that implements the RCTBridgeModule protocol, and wrap the function that you want to make available to JavaScript in RCT_EXPORT_METHOD. Additionally, the class itself must be explicitly exported with RCT_EXPORT_MODULE();.

// Objective-C + } +}

Extensibility

It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you've already built, and can import and use your favorite native libraries.

Creating iOS modules

To create a simple iOS module, create a new class that implements the RCTBridgeModule protocol, and wrap the function that you want to make available to JavaScript in RCT_EXPORT_METHOD. Additionally, the class itself must be explicitly exported with RCT_EXPORT_MODULE();.

// Objective-C #import "RCTBridgeModule.h" @@ -113,24 +132,28 @@ } @end
// JavaScript -var React = require('react-native'); -var { NativeModules, Text } = React; +import React, { + Component, + NativeModules, + Text +} from 'react-native'; -var Message = React.createClass({ - getInitialState() { - return { text: 'Goodbye World.' }; - }, +class Message extends Component { + constructor(props) { + super(props); + this.state = { text: 'Goodbye World.' }; + } componentDidMount() { NativeModules.MyCustomModule.processString(this.state.text, (text) => { this.setState({text}); }); - }, - render: function() { + } + render() { return ( <Text>{this.state.text}</Text> ); } -});

Creating iOS views

Custom iOS views can be exposed by subclassing RCTViewManager, implementing a -(UIView *)view method, and exporting properties with the RCT_EXPORT_VIEW_PROPERTY macro. Then a simple JavaScript file connects the dots.

// Objective-C +}

Creating iOS views

Custom iOS views can be exposed by subclassing RCTViewManager, implementing a -(UIView *)view method, and exporting properties with the RCT_EXPORT_VIEW_PROPERTY macro. Then a simple JavaScript file connects the dots.

// Objective-C #import "RCTViewManager.h" @@ -149,20 +172,22 @@ RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString); @end
// JavaScript -var React = require('react-native'); -var { requireNativeComponent } = React; +import React, { + Component, + requireNativeComponent +} from 'react-native'; -class MyCustomView extends React.Component { +var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); + +export default class MyCustomView extends Component { + static propTypes = { + myCustomProperty: React.PropTypes.oneOf(['a', 'b']), + }; render() { return <NativeMyCustomView {...this.props} />; } } -MyCustomView.propTypes = { - myCustomProperty: React.PropTypes.oneOf(['a', 'b']), -}; - -var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); -module.exports = MyCustomView;

Creating Android modules

Likewise, Android also supports custom extensions, the methods are just slightly different.

To create a simple module in Android, create a new class that extends the ReactContextBaseJavaModule class, and annotate the function that you want to make available to JavaScript with @ReactMethod. Additionally, the class itself must be registered in the ReactPackage of your React Native application.

// Java +

Creating Android modules

Likewise, Android also supports custom extensions, the methods are just slightly different.

To create a simple module in Android, create a new class that extends the ReactContextBaseJavaModule class, and annotate the function that you want to make available to JavaScript with @ReactMethod. Additionally, the class itself must be registered in the ReactPackage of your React Native application.

// Java public class MyCustomModule extends ReactContextBaseJavaModule { @@ -174,35 +199,33 @@ public class MyCustomModule extends }
// JavaScript -var React = require('react-native'); -var { NativeModules, Text } = React; -var Message = React.createClass({ - getInitialState() { - return { text: 'Goodbye World.' }; +import React, { + Component, + NativeModules, + Text +} from 'react-native'; +class Message extends Component { + constructor(props) { + super(props); + this.state = { text: 'Goodbye World.' }; }, componentDidMount() { NativeModules.MyCustomModule.processString(this.state.text, (text) => { this.setState({text}); }); - }, - render: function() { + } + render() { return ( <Text>{this.state.text}</Text> ); } -}); -

Creating Android views

Custom Android views can be exposed by extending SimpleViewManager, implementing a createViewInstance and getName methods, and exporting properties with the @UIProp annotation. Then a simple JavaScript file connects the dots.

// Java +} +

Creating Android views

Custom Android views can be exposed by extending SimpleViewManager, implementing a createViewInstance and getName methods, and exporting properties with the @ReactProp annotation. Then a simple JavaScript file connects the dots.

// Java public class MyCustomViewManager extends SimpleViewManager<MyCustomView> { - - private static final String REACT_CLASS = "MyCustomView"; - - @UIProp(UIProp.Type.STRING) - public static final String PROP_MY_CUSTOM_PROPERTY = "myCustomProperty"; - @Override public String getName() { - return REACT_CLASS; + return "MyCustomView"; } @Override @@ -210,32 +233,29 @@ public class MyCustomViewManager extends < return new MyCustomView(reactContext); } - @Override - public void updateView(MyCustomView view, ReactStylesDiffMap props) { - super.updateView(view, props); - - if (props.hasKey(PROP_MY_CUSTOM_PROPERTY)) { - view.setMyCustomProperty(props.getString(PROP_MY_CUSTOM_PROPERTY)); - } + @ReactProp(name = "myCustomProperty") + public void setMyCustomProperty(MyCustomView view, String value) { + view.setMyCustomProperty(value); } }
// JavaScript -var React = require('react-native'); -var { requireNativeComponent } = React; +import React, { + Component, + requireNativeComponent +} from 'react-native'; -class MyCustomView extends React.Component { +var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); + +export default class MyCustomView extends Component { + static propTypes = { + myCustomProperty: React.PropTypes.oneOf(['a', 'b']), + }; render() { return <NativeMyCustomView {...this.props} />; } } -MyCustomView.propTypes = { - myCustomProperty: React.PropTypes.oneOf(['a', 'b']), -}; - -var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); -module.exports = MyCustomView; -
© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/js/scripts.js b/js/scripts.js index 8e3d9d440a7..9bed77965b3 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -42,11 +42,4 @@ modal.classList.remove('modal-open'); } - // Algolia - docsearch({ - apiKey: 'e3d767b736584dbe6d4c35f7cf7d4633', - indexName: 'react-native', - inputSelector: '#algolia-doc-search' - }); - }()); diff --git a/releases/0.23/docs/android-building-from-source.html b/releases/0.23/docs/android-building-from-source.html index 657753c5133..8542ce1a440 100644 --- a/releases/0.23/docs/android-building-from-source.html +++ b/releases/0.23/docs/android-building-from-source.html @@ -1,6 +1,6 @@ -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 +Building React Native from source – React Native | A framework for building native apps using React

Building React Native from source #

Edit on GitHub

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

Prerequisites #

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

Make sure you have the following installed:

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

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

sdk.dir=absolute_path_to_android_sdk ndk.dir=absolute_path_to_android_ndk

Example:

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

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:

... +ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e

Download links for Android NDK #

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

You can find further instructions on the official page.

Building the source #

1. Installing the fork #

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

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

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

2. Adding gradle dependencies #

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

... dependencies { classpath 'com.android.tools.build:gradle:1.3.1' classpath 'de.undercouch:gradle-download-task:2.0.0' diff --git a/releases/0.23/versions.html b/releases/0.23/versions.html index 5469d65e6b5..433c57abc25 100644 --- a/releases/0.23/versions.html +++ b/releases/0.23/versions.html @@ -1,4 +1,4 @@ -Documentation archive – React Native | A framework for building native apps using React

React Native Versions

React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

masterDocs
0.23-rcDocsRelease Notes
(current) 0.22DocsRelease Notes
0.21DocsRelease Notes
0.20DocsRelease Notes
0.19DocsRelease Notes
0.18DocsRelease Notes
© 2016 Facebook Inc.

React Native Versions

React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

masterDocs
0.24-rcDocsRelease Notes
(current) 0.23DocsRelease Notes
0.22DocsRelease Notes
0.21DocsRelease Notes
0.20DocsRelease Notes
0.19DocsRelease Notes
0.18DocsRelease Notes
© 2016 Facebook Inc.

Apps using React Native

The following is a list of some of the public apps using React Native and are published on the Apple App Store or the Google Play Store. Not all are implemented 100% in React Native -- many are hybrid native/React Native. Can you tell which parts are which? :)

Want to add your app? Found an app that no longer works or no longer uses React Native? Please submit a pull request on GitHub to update this page!

Featured Apps

These are some of the most well-crafted React Native apps that we have come across.
Be sure to check them out to get a feel for what React Native is capable of!

All Apps

Not all apps can be featured, otherwise we would have to create some other category like "super featured" and that's just silly. But that doesn't mean you shouldn't check these apps out!

CANDDi

CANDDi

iOS -Android

By CANDDi LTD.

DockMan

DockMan

iOS -Android

By Genki Takiuchi (s21g Inc.)

Blog post

Eat or Not

Eat or Not

iOS -Android

By Sharath Prabhal

Fixt

Fixt

iOS -Android

By Fixt

Hover

Hover

iOS -Android

By KevinEJohn

Kakapo

Kakapo

iOS -Android

By Daniel Levitt

MaxReward - Android

MaxReward - Android

iOS -Android

By Neil Ma

ShareHows

ShareHows

iOS -Android

By Dobbit Co., Ltd.

TeamWarden

TeamWarden

iOS -Android

By nittygritty.net

WEARVR

WEARVR

iOS -Android

By WEARVR LLC

天才段子手

天才段子手

iOS -Android

By Ran Zhao&Ji Zhao

うたよみん

うたよみん

iOS -Android

By Takayuki IMAI

© 2016 Facebook Inc.

Apps using React Native

The following is a list of some of the public apps using React Native and are published on the Apple App Store or the Google Play Store. Not all are implemented 100% in React Native -- many are hybrid native/React Native. Can you tell which parts are which? :)

Want to add your app? Found an app that no longer works or no longer uses React Native? Please submit a pull request on GitHub to update this page!

Featured Apps

These are some of the most well-crafted React Native apps that we have come across.
Be sure to check them out to get a feel for what React Native is capable of!

All Apps

Not all apps can be featured, otherwise we would have to create some other category like "super featured" and that's just silly. But that doesn't mean you shouldn't check these apps out!

breathe Meditation Timer

breathe Meditation Timer

iOS -Android

By idearockers UG

CANDDi

CANDDi

iOS -Android

By CANDDi LTD.

Chillin'

Chillin'

iOS -Android

By Chillin LLC

DockMan

DockMan

iOS -Android

By Genki Takiuchi (s21g Inc.)

Blog post

Eat or Not

Eat or Not

iOS -Android

By Sharath Prabhal

Fixt

Fixt

iOS -Android

By Fixt

Hover

Hover

iOS -Android

By KevinEJohn

Kakapo

Kakapo

iOS -Android

By Daniel Levitt

MaxReward - Android

MaxReward - Android

iOS -Android

By Neil Ma

Mobabuild

Mobabuild

iOS -Android

By Sercan Demircan ( @sercanov )

ShareHows

ShareHows

iOS -Android

By Dobbit Co., Ltd.

TeamWarden

TeamWarden

iOS -Android

By nittygritty.net

WEARVR

WEARVR

iOS -Android

By WEARVR LLC

天才段子手

天才段子手

iOS -Android

By Ran Zhao&Ji Zhao

うたよみん

うたよみん

iOS -Android

By Takayuki IMAI

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/support.html b/support.html index 565dd836eb1..b8b3f429df4 100644 --- a/support.html +++ b/support.html @@ -1,4 +1,4 @@ -Support – React Native | A framework for building native apps using React

Need help?

React Native is worked on full-time by Facebook's product infrastructure user interface engineering teams. They're often around and available for questions.

Community translation #

The following is a list of translated docs offered by community volunteers. Send a pull request to fill the list!

Stack Overflow #

Many members of the community use Stack Overflow to ask questions. Read through the existing questions tagged with react-native or ask your own!

Chat #

Join us in #reactnative on Reactiflux.

Twitter #

#reactnative hash tag on Twitter is used to keep up with the latest React Native news.

© 2016 Facebook Inc.

Need help?

React Native is worked on full-time by Facebook's product infrastructure user interface engineering teams. They're often around and available for questions.

Community translation #

The following is a list of translated docs offered by community volunteers. Send a pull request to fill the list!

Stack Overflow #

Many members of the community use Stack Overflow to ask questions. Read through the existing questions tagged with react-native or ask your own!

Chat #

Join us in #react-native on Reactiflux.

Product Pains #

React Native uses Product Pains for feature requests. It has a voting system to surface which issues are most important to the community. GitHub issues should only be used for bugs.

Twitter #

#reactnative hash tag on Twitter is used to keep up with the latest React Native news.

© 2016 Facebook Inc.
\ No newline at end of file + + docsearch({ + apiKey: '2c98749b4a1e588efec53b2acec13025', + indexName: 'react-native-versions', + inputSelector: '#algolia-doc-search', + algoliaOptions: { facetFilters: [ "tags:0.23" ], hitsPerPage: 5 } + }); + \ No newline at end of file diff --git a/versions.html b/versions.html index 7439f5ec532..1d3a6a3baa5 100644 --- a/versions.html +++ b/versions.html @@ -1,4 +1,4 @@ -Documentation archive – React Native | A framework for building native apps using React

React Native Versions

React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

masterDocs
0.24-rcDocsRelease Notes
0.23-rcDocsRelease Notes
(current) 0.22DocsRelease Notes
0.21DocsRelease Notes
0.20DocsRelease Notes
0.19DocsRelease Notes
0.18DocsRelease Notes
© 2016 Facebook Inc.

React Native Versions

React Native is following a 2-week train release. Every two weeks, a Release Candidate (rc) branch is created off of master and the previous rc branch is being officially released.

masterDocs
0.24-rcDocsRelease Notes
(current) 0.23DocsRelease Notes
0.22DocsRelease Notes
0.21DocsRelease Notes
0.20DocsRelease Notes
0.19DocsRelease Notes
0.18DocsRelease Notes
© 2016 Facebook Inc.
\ No newline at end of file