diff --git a/docs/accessibility.html b/docs/accessibility.html index 4a5fb05cdf4..a03472b83ef 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,4 +1,4 @@ -
Accessibility # | Edit on GitHub |
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.
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}’.
Accessibility # | Edit on GitHub |
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.
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}’.
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.
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:
ActionSheetIOS # | Edit on GitHub |
Display an iOS action sheet. The options object must contain one or more
-of:
options (array of strings) - a list of button titles (required)cancelButtonIndex (int) - index of cancel button in optionsdestructiveButtonIndex (int) - index of destructive button in optionstitle (string) - a title to show above the action sheetmessage (string) - a message to show below the titleDisplay the iOS share sheet. The options object should contain
+
ActionSheetIOS # | Edit on GitHub |
Display an iOS action sheet. The options object must contain one or more
+of:
options (array of strings) - a list of button titles (required)cancelButtonIndex (int) - index of cancel button in optionsdestructiveButtonIndex (int) - index of destructive button in optionstitle (string) - a title to show above the action sheetmessage (string) - a message to show below the titleDisplay the iOS share sheet. The options object should contain
one or both of:
message (string) - a message to shareurl (string) - a URL to shareNOTE: 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 |
ActivityIndicatorIOS # | Edit on GitHub |
Whether to show the indicator (true, the default) or hide it (false).
The foreground color of the spinner (default is gray).
Whether the indicator should hide when not animating (true by default).
Invoked on mount and layout changes with
{nativeEvent: { layout: {x, y, width, height}}}.
Size of the indicator. Small has a height of 20, large has a height of 36.
Examples # | Edit on GitHub |
ActivityIndicatorIOS # | Edit on GitHub |
Whether to show the indicator (true, the default) or hide it (false).
The foreground color of the spinner (default is gray).
Whether the indicator should hide when not animating (true by default).
Invoked on mount and layout changes with
{nativeEvent: { layout: {x, y, width, height}}}.
Size of the indicator. Small has a height of 20, large has a height of 36.
Examples # | Edit on GitHub |
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 # | Edit on GitHub |
Launches an alert dialog with the specified title and message.
Optionally provide a list of buttons. Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button.
This is an API that works both on iOS and Android and can show static alerts. To show an alert that prompts the user to enter some information, @@ -13,16 +13,17 @@ of a neutral, negative and a positive button:
Examples # | Edit on GitHub |
Examples # | Edit on GitHub |
AlertIOS # | Edit on GitHub |
The AlertsIOS utility provides two functions: alert and prompt. All
+
AlertIOS # | Edit on GitHub |
The AlertsIOS utility provides two functions: alert and prompt. All
functionality available through AlertIOS.alert is also available in the
cross-platform Alert.alert, which we recommend you use if you don't need
iOS-specific functionality.
AlertIOS.prompt allows you to prompt the user for input inside of an
-alert popup.
Creates a popup to alert the user. See +alert popup.
Creates a popup to alert the user. See Alert.
callbackOrButtons -- This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called when the user taps 'OK'.
If passed an array of button configurations, each button should include
@@ -10,7 +10,7 @@ a text key, as well as optional onPress and styl
style should be one of 'default', 'cancel' or 'destructive'.
Example:
Prompt the user to enter some text.
callbackOrButtons -- This optional argument should be either a +);
Prompt the user to enter some text.
callbackOrButtons -- This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called with the prompt's value when the user taps 'OK'.
If passed an array of button configurations, each button should include
a text key, as well as optional onPress and style keys (see example).
@@ -31,14 +31,15 @@ a text key, as well as optional onPress and styl
'default'
)
Examples # | Edit on GitHub |
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.
Assuming you have the Android SDK installed, run android to open the Android SDK Manager.
Make sure you have the following installed:
build.gradle)build.gradle)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:
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.
Assuming you have the Android SDK installed, run android to open the Android SDK Manager.
Make sure you have the following installed:
build.gradle)build.gradle)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:
Example:
You can find further instructions on the official page.
First, you need to install react-native from your fork. For example, to install the master branch from the official repo, run the following:
Alternatively, you can clone the repo to your node_modules directory and run npm install inside the cloned repo.
Add gradle-download-task as dependency in android/build.gradle:
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.
On Mac, if you have installed XCode, Git is already installed, otherwise run the following:
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.
brew install android-sdkIMPORTANT: Make sure the ANDROID_HOME environment variable points to your existing Android SDK:
On Mac, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:
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.
On Mac, if you have installed XCode, Git is already installed, otherwise run the following:
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.
brew install android-sdkIMPORTANT: Make sure the ANDROID_HOME environment variable points to your existing Android SDK:
On Mac, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:
On Linux, add this to your ~/.bashrc, ~/.bash_profile or whatever your shell uses:
On Windows, go to Control Panel -> System and Security -> System -> Change settings -> Advanced -> Environment variables -> New
NOTE: You need to restart the Command Prompt (Windows) / Terminal Emulator (Mac OS X, Linux) to apply the new Environment variables.
React Native Android use gradle as a build system. We recommend to enable gradle daemon functionality which may result in up to 50% improvement in incremental build times for changes in java code. Learn here how to enable it for your platform.
android); in the window that appears make sure you check:

Genymotion is much easier to set up than stock Google emulators. However, it's only free for personal use. If you want to use the stock Google emulator, see below.
android; in the window that appears make sure you check:/usr/local/opt/android-sdk/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM_<version>.dmg and installing the package within.android avd and click on Create...
-
Start...The Visual Studio Emulator for Android is a free android emulator that is hardware accelerated via Hyper-V. It doesn't require you to install Visual Studio at all.
To use it with react-native you just have to add a key and value to your registry:
regedit.exeHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK ToolsAndroid SDK Tools and choose New > String ValuePathPath Key and set the value to C:\Program Files\Android\sdk. The path value might be different on your machine.You will also need to run the command adb reverse tcp:8081 tcp:8081 with this emulator.
Then restart the emulator and when it runs you can just do react-native run-android as usual.
You can use any editor to edit JavaScript. If you want to use Android Studio to work on native code, from the Welcome screen of Android Studio choose "Import project" and select the android folder of your app.
In case you encounter

Start...The Visual Studio Emulator for Android is a free android emulator that is hardware accelerated via Hyper-V. It doesn't require you to install Visual Studio at all.
To use it with react-native you just have to add a key and value to your registry:
regedit.exeHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK ToolsAndroid SDK Tools and choose New > String ValuePathPath Key and set the value to C:\Program Files\Android\sdk. The path value might be different on your machine.You will also need to run the command adb reverse tcp:8081 tcp:8081 with this emulator.
Then restart the emulator and when it runs you can just do react-native run-android as usual.
You can use any editor to edit JavaScript. If you want to use Android Studio to work on native code, from the Welcome screen of Android Studio choose "Import project" and select the android folder of your app.
In case you encounter
try downgrading your Gradle version to 1.2.3 in <project-name>/android/build.gradle (https://github.com/facebook/react-native/issues/2720)
Profiling Android UI Performance # | Edit on GitHub |
We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).
The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...
Make sure that JS dev mode is OFF!
You should see
__DEV__ === false, development-level warning are OFF, performance optimizations are ONin your application logs (which you can view usingadb logcat)
Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by markers start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.
NOTE:
Systrace support was added in react-native
v0.15. You will need to build with that version to collect a trace.
First, connect a device that exhibits the stuttering you want to investigate to your computer via USB and get it to the point right before the navigation/animation you want to profile. Run systrace as follows
A quick breakdown of this command:
time is the length of time the trace will be collected in secondssched, gfx, and view are the android SDK tags (collections of markers) we care about: sched gives you information about what's running on each core of your phone, gfx gives you graphics info such as frame boundaries, and view gives you information about measure, layout, and draw passes-a <your_package_name> enables app-specific markers, specifically the ones built into the React Native framework. your_package_name can be found in the AndroidManifest.xml of your app and looks like com.example.appOnce the trace starts collecting, perform the animation or interaction you care about. At the end of the trace, systrace will give you a link to the trace which you can open in your browser.
After opening the trace in your browser (preferably Chrome), you should see something like this:

HINT: Use the WASD keys to strafe and zoom
The first thing you should do is highlight the 16ms frame boundaries if you haven't already done that. Check this checkbox at the top right of the screen:

You should see zebra stripes as in the screenshot above. If you don't, try profiling on a different device: Samsung has been known to have issues displaying vsyncs while the Nexus series is generally pretty reliable.
Scroll until you see (part of) the name of your package. In this case, I was profiling com.facebook.adsmanager, which shows up as book.adsmanager because of silly thread name limits in the kernel.
On the left side, you'll see a set of threads which correspond to the timeline rows on the right. There are three/four threads we care about for our purposes: the UI thread (which has your package name or the name UI Thread), mqt_js and mqt_native_modules. If you're running on Android 5+, we also care about the Render Thread.
This is where standard android measure/layout/draw happens. The thread name on the right will be your package name (in my case book.adsmanager) or UI Thread. The events that you see on this thread should look something like this and have to do with Choreographer, traversals, and DispatchUI:

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

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

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

A smooth animation should look something like the following:

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

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

In this case, the UI and render threads are the ones that have work crossing frame boundaries. The UI that we're trying to render on each frame is requiring too much work to be done. In this case, the problem lies in the native views being rendered.
At this point, you'll have some very helpful information to inform your next steps.
If you identified a JS problem, look for clues in the specific JS that you're executing. In the scenario above, we see RCTEventEmitter being called multiple times per frame. Here's a zoom-in of the JS thread from the trace above:

This doesn't seem right. Why is it being called so often? Are they actually different events? The answers to these questions will probably depend on your product code. And many times, you'll want to look into shouldComponentUpdate.
TODO: Add more tools for profiling JS
If you identified a native UI problem, there are usually two scenarios:
In the first scenario, you'll see a trace that has the UI thread and/or Render Thread looking like this:

Notice the long amount of time spent in DrawFrame that crosses frame boundaries. This is time spent waiting for the GPU to drain its command buffer from the previous frame.
To mitigate this, you should:
renderToHardwareTextureAndroid for complex, static content that is being animated/transformed (e.g. the Navigator slide/alpha animations)needsOffscreenAlphaCompositing, which is disabled by default, as it greatly increases the per-frame load on the GPU in most cases.If these don't help and you want to dig deeper into what the GPU is actually doing, you can check out Tracer for OpenGL ES.
In the second scenario, you'll see something more like this:

Notice that first the JS thread thinks for a bit, then you see some work done on the native modules thread, followed by an expensive traversal on the UI thread.
There isn't an easy way to mitigate this unless you're able to postpone creating new UI until after the interaction, or you are able to simplify the UI you're creating. The react native team is working on a infrastructure level solution for this that will allow new UI to be created and configured off the main thread, allowing the interaction to continue smoothly.
If you are confused or stuck, please post ask on Stack Overflow with the react-native tag. If you are unable to get a response there, or find an issue with a core component, please File a Github issue.
Profiling Android UI Performance # | Edit on GitHub |
We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).
The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...
Make sure that JS dev mode is OFF!
You should see
__DEV__ === false, development-level warning are OFF, performance optimizations are ONin your application logs (which you can view usingadb logcat)
Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by markers start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.
NOTE:
Systrace support was added in react-native
v0.15. You will need to build with that version to collect a trace.
First, connect a device that exhibits the stuttering you want to investigate to your computer via USB and get it to the point right before the navigation/animation you want to profile. Run systrace as follows
A quick breakdown of this command:
time is the length of time the trace will be collected in secondssched, gfx, and view are the android SDK tags (collections of markers) we care about: sched gives you information about what's running on each core of your phone, gfx gives you graphics info such as frame boundaries, and view gives you information about measure, layout, and draw passes-a <your_package_name> enables app-specific markers, specifically the ones built into the React Native framework. your_package_name can be found in the AndroidManifest.xml of your app and looks like com.example.appOnce the trace starts collecting, perform the animation or interaction you care about. At the end of the trace, systrace will give you a link to the trace which you can open in your browser.
After opening the trace in your browser (preferably Chrome), you should see something like this:

HINT: Use the WASD keys to strafe and zoom
The first thing you should do is highlight the 16ms frame boundaries if you haven't already done that. Check this checkbox at the top right of the screen:

You should see zebra stripes as in the screenshot above. If you don't, try profiling on a different device: Samsung has been known to have issues displaying vsyncs while the Nexus series is generally pretty reliable.
Scroll until you see (part of) the name of your package. In this case, I was profiling com.facebook.adsmanager, which shows up as book.adsmanager because of silly thread name limits in the kernel.
On the left side, you'll see a set of threads which correspond to the timeline rows on the right. There are three/four threads we care about for our purposes: the UI thread (which has your package name or the name UI Thread), mqt_js and mqt_native_modules. If you're running on Android 5+, we also care about the Render Thread.
This is where standard android measure/layout/draw happens. The thread name on the right will be your package name (in my case book.adsmanager) or UI Thread. The events that you see on this thread should look something like this and have to do with Choreographer, traversals, and DispatchUI:

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

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

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

A smooth animation should look something like the following:

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

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

In this case, the UI and render threads are the ones that have work crossing frame boundaries. The UI that we're trying to render on each frame is requiring too much work to be done. In this case, the problem lies in the native views being rendered.
At this point, you'll have some very helpful information to inform your next steps.
If you identified a JS problem, look for clues in the specific JS that you're executing. In the scenario above, we see RCTEventEmitter being called multiple times per frame. Here's a zoom-in of the JS thread from the trace above:

This doesn't seem right. Why is it being called so often? Are they actually different events? The answers to these questions will probably depend on your product code. And many times, you'll want to look into shouldComponentUpdate.
TODO: Add more tools for profiling JS
If you identified a native UI problem, there are usually two scenarios:
In the first scenario, you'll see a trace that has the UI thread and/or Render Thread looking like this:

Notice the long amount of time spent in DrawFrame that crosses frame boundaries. This is time spent waiting for the GPU to drain its command buffer from the previous frame.
To mitigate this, you should:
renderToHardwareTextureAndroid for complex, static content that is being animated/transformed (e.g. the Navigator slide/alpha animations)needsOffscreenAlphaCompositing, which is disabled by default, as it greatly increases the per-frame load on the GPU in most cases.If these don't help and you want to dig deeper into what the GPU is actually doing, you can check out Tracer for OpenGL ES.
In the second scenario, you'll see something more like this:

Notice that first the JS thread thinks for a bit, then you see some work done on the native modules thread, followed by an expensive traversal on the UI thread.
There isn't an easy way to mitigate this unless you're able to postpone creating new UI until after the interaction, or you are able to simplify the UI you're creating. The react native team is working on a infrastructure level solution for this that will allow new UI to be created and configured off the main thread, allowing the interaction to continue smoothly.
If you are confused or stuck, please post ask on Stack Overflow with the react-native tag. If you are unable to get a response there, or find an issue with a core component, please File a Github issue.
Animated # | Edit on GitHub |
Animations are an important part of modern UX, and the Animated
+
Animated # | Edit on GitHub |
Animations are an important part of modern UX, and the Animated
library is designed to make them fluid, powerful, and easy to build and
maintain.
The simplest workflow is to create an Animated.Value, hook it up to one or
more style attributes of an animated component, and then drive updates either
@@ -58,18 +58,18 @@ event loop. This does influence the API, so keep that in mind when it seems a
little trickier to do something compared to a fully synchronous system.
Checkout Animated.Value.addListener as a way to work around some of these
limitations, but use it sparingly since it might have performance
-implications in the future.
Animates a value from an initial velocity to zero based on a decay -coefficient.
Animates a value along a timed easing curve. The Easing module has tons
-of pre-defined curves, or you can use your own function.
Spring animation based on Rebound and Origami. Tracks velocity state to
-create fluid motions as the toValue updates, and can be chained together.
Creates a new Animated value composed from two Animated values added -together.
Creates a new Animated value composed from two Animated values multiplied -together.
Creates a new Animated value that is the (non-negative) modulo of the -provided Animated value
Starts an animation after the given delay.
Starts an array of animations in order, waiting for each to complete +implications in the future.
Animates a value from an initial velocity to zero based on a decay +coefficient.
Animates a value along a timed easing curve. The Easing module has tons
+of pre-defined curves, or you can use your own function.
Spring animation based on Rebound and Origami. Tracks velocity state to
+create fluid motions as the toValue updates, and can be chained together.
Creates a new Animated value composed from two Animated values added +together.
Creates a new Animated value composed from two Animated values multiplied +together.
Creates a new Animated value that is the (non-negative) modulo of the +provided Animated value
Starts an animation after the given delay.
Starts an array of animations in order, waiting for each to complete before starting the next. If the current running animation is stopped, no -following animations will be started.
Starts an array of animations all at the same time. By default, if one +following animations will be started.
Starts an array of animations all at the same time. By default, if one
of the animations is stopped, they will all be stopped. You can override
-this with the stopTogether flag.
Array of animations may run in parallel (overlap), but are started in -sequence with successive delays. Nice for doing trailing effects.
Takes an array of mappings and extracts values from each arg accordingly,
+this with the stopTogether flag.
Array of animations may run in parallel (overlap), but are started in +sequence with successive delays. Nice for doing trailing effects.
Takes an array of mappings and extracts values from each arg accordingly,
then calls setValue on the mapped outputs. e.g.
Make any React component Animatable. Used to create Animated.View, etc.
Standard value class for driving animations. Typically initialized with + ]),
Make any React component Animatable. Used to create Animated.View, etc.
Standard value for driving animations. One Animated.Value can drive
multiple properties in a synchronized fashion, but can only be driven by one
mechanism at a time. Using a new mechanism (e.g. starting a new animation,
-or calling setValue) will stop any previous ones.
Directly set the value. This will stop any animations running on the value -and update all the bound properties.
Sets an offset that is applied on top of whatever value is set, whether via
+or calling setValue) will stop any previous ones.
Directly set the value. This will stop any animations running on the value +and update all the bound properties.
Sets an offset that is applied on top of whatever value is set, whether via
setValue, an animation, or Animated.event. Useful for compensating
things like the start of a pan gesture.
Merges the offset value into the base value and resets the offset to zero. -The final output of the value is unchanged.
Adds an asynchronous listener to the value so you can observe updates from +The final output of the value is unchanged.
Adds an asynchronous listener to the value so you can observe updates from animations. This is useful because there is no way to -synchronously read the value because it might be driven natively.
Stops any running animation or tracking. callback is invoked with the
+synchronously read the value because it might be driven natively.
Stops any running animation or tracking. callback is invoked with the
final value after stopping the animation, which is useful for updating
-state to match the animation position with layout.
Interpolates the value before updating the property, e.g. mapping 0-1 to -0-10.
Typically only used internally, but could be used by a custom Animation -class.
Typically only used internally.
Typically only used internally.
2D Value for driving 2D animations, such as pan gestures. Almost identical +state to match the animation position with layout.
Interpolates the value before updating the property, e.g. mapping 0-1 to +0-10.
Typically only used internally, but could be used by a custom Animation +class.
Typically only used internally.
Typically only used internally.
2D Value for driving 2D animations, such as pan gestures. Almost identical
API to normal Animated.Value, but multiplexed. Contains two regular
Animated.Values under the hood. Example:
Animated.Value, but multiplexed. Contains two regula
</Animated.View>
);
}
- }Converts {x, y} into {left, top} for use in style, e.g.
Converts {x, y} into a useable translation transform, e.g.
Converts {x, y} into {left, top} for use in style, e.g.
Converts {x, y} into a useable translation transform, e.g.
Examples # | Edit on GitHub |
Animations # | Edit on GitHub |
Fluid, meaningful animations are essential to the mobile user experience. Like +
Animations # | Edit on GitHub |
Fluid, meaningful animations are essential to the mobile user experience. Like
everything in React Native, Animation APIs for React Native are currently under
development, but have started to coalesce around two complementary systems:
LayoutAnimation for animated global layout transactions, and Animated for
@@ -149,23 +149,25 @@ row below which would otherwise require explicit coordination between the
components in order to animate them all in sync.
Note that although LayoutAnimation is very powerful and can be quite useful,
it provides much less control than Animated and other animation libraries, so
you may need to use another approach if you can't get LayoutAnimation to do
-what you want.
Note that in order to get this to work on Android you need to set the following flags via UIManager:

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

Note that in order to get this to work on Android </View> ); } -});
This example uses a preset value, you can customize the animations as +};
This example uses a preset value, you can customize the animations as you need, see LayoutAnimation.js for more information.
requestAnimationFrame is a polyfill from the browser that you might be
familiar with. It accepts a function as its only argument and calls that
@@ -201,13 +203,14 @@ provides a selection of popular ea
that can be applied to make your animations more pleasing.
This library does not ship with React Native - in order to use it on
your project, you will need to install it with npm i react-tween-state
--save from your project directory.
npm i react-tween-state
duration: 1000,
endValue: this.state.opacity === 0.2 ? 1 : 0.2,
});
- },
+ }
render() {
return (
@@ -227,8 +230,10 @@ your project, you will need to install it with npm i react-tween-state
</TouchableWithoutFeedback>
</View>
)
- },
-});
Here we animated the opacity, but as you might guess, we can animate any + } +} + +reactMixin.onClass(App, tweenState.Mixin);

Here we animated the opacity, but as you might guess, we can animate any numeric value. Read more about react-tween-state in its README.
Rebound.js is a JavaScript port of
Rebound for Android. It is
@@ -243,7 +248,12 @@ by React Native on Navigator and WarningBox.
You can also clamp the spring values so that they don't overshoot and
+} You can also clamp the spring values so that they don't overshoot and
oscillate around the end value. In the above example, we would add
AppState is frequently used to determine the intent and proper behavior when
handling push notifications. This example will only ever appear to say "Current state is: active" because
the app is only visible to the user when in the AppStateIOS is frequently used to determine the intent and proper behavior when
handling push notifications. This example will only ever appear to say "Current state is: active" because
the app is only visible to the user when in the // TODO: getCurrentAppState callback seems to be called at a really late stage
+state will happen only momentarily. // TODO: getCurrentAppState callback seems to be called at a really late stage
// after app launch. Trying to get currentState when mounting App component
// will likely to have the initial value here.
// Initialize to 'active' instead of null. AsyncStorage is a simple, asynchronous, persistent, key-value storage
+ AsyncStorage is a simple, asynchronous, persistent, key-value storage
system that is global to the app. It should be used instead of LocalStorage. It is recommended that you use an abstraction on top of AsyncStorage instead
of AsyncStorage directly for anything more than light usage since it
-operates globally. This JS code is a simple facade over the native iOS implementation to provide
-a clear JS API, real Error objects, and simple non-multi functions. Each
-method returns a Fetches Sets Returns a Merges existing value with input value, assuming they are stringified json.
+operates globally. On iOS, AsyncStorage is backed by native code that stores small values in a serialized
+dictionary and larger values in separate files. On Android, AsyncStorage will use either
+RocksDB or SQLite based on what is available. This JS code is a simple facade that
+provides a clear JS API, real Error objects, and simple non-multi functions. Each
+method returns a Fetches Sets Returns a Merges existing value with input value, assuming they are stringified json.
Returns a Example: Erases all AsyncStorage for all clients, libraries, etc. You probably
+}); 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 Gets all keys known to the app, for all callers, libraries, etc. Returns a Example: see multiGet for example Flushes any pending requests using a single multiget multiGet invokes callback with an array of key-value pair arrays that
+own keys instead. Returns a Gets all keys known to the app, for all callers, libraries, etc. Returns a Example: see multiGet for example Flushes any pending requests using a single multiget multiGet invokes callback with an array of key-value pair arrays that
matches the input format of multiSet. Returns a multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']]) Example: multiSet and multiMerge take arrays of key-value array pairs that match
-the output of multiGet, e.g. Returns a multiSet([['k1', 'val1'], ['k2', 'val2']], cb); Example: see multiMerge for an example Delete all the keys in the Example: multiSet and multiMerge take arrays of key-value array pairs that match
+the output of multiGet, e.g. Returns a multiSet([['k1', 'val1'], ['k2', 'val2']], cb); Example: see multiMerge for an example Delete all the keys in the Example: Merges existing values with input values, assuming they are stringified
+}); Merges existing values with input values, assuming they are stringified
json. Returns a Not supported by all native implementations. Example: Detect hardware back button presses, and programmatically invoke the default back button
+ 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: Saves the image to the camera roll / gallery. On Android, the tag is a local URI, such as On iOS, the tag can be one of the following: Returns a Promise which when resolved will be passed the new URI. Returns a Promise with photo identifier objects from the local camera
+ Saves the image to the camera roll / gallery. On Android, the tag is a local URI, such as On iOS, the tag can be one of the following: Returns a Promise which when resolved will be passed the new URI. Returns a Promise with photo identifier objects from the local camera
roll of the device matching shape defined by @param {object} params See Returns a Promise which when resolved will be of shape Get content of string type, this method returns a Get content of string type, this method returns a Set content of string type. You can use following code to set clipboard content Set content of string type. You can use following code to set clipboard content @param the content to be stored in the clipboard. The following formats are supported: For the named colors, React Native follows the CSS3 specification: The following formats are supported: For the named colors, React Native follows the CSS3 specification: In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques. React Native is inspired by React, so the basic idea of the information flow is similar. The flow in React is one-directional. We maintain a hierarchy of components, in which each component depends only on its parent and own internal state. We do this with properties: data is passed from a parent to its children in a top-down manner. If we have an ancestor component that rely on the state of its descendant, the recommended solution would be to pass down a callback that would be used by the descendant to update the ancestor. The same concept applies to React Native. As long as we are building our application purely within the framework, we can drive our app with properties and callbacks. But, when we mix React Native and native components, we need some special, cross-language mechanisms that would allow us to pass information between them. Properties are the simplest way of cross-component communication. So we need a way to pass properties both from native to React Native, and from React Native to native. In order to embed a React Native view in a native component, we use In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques. React Native is inspired by React, so the basic idea of the information flow is similar. The flow in React is one-directional. We maintain a hierarchy of components, in which each component depends only on its parent and own internal state. We do this with properties: data is passed from a parent to its children in a top-down manner. If we have an ancestor component that rely on the state of its descendant, the recommended solution would be to pass down a callback that would be used by the descendant to update the ancestor. The same concept applies to React Native. As long as we are building our application purely within the framework, we can drive our app with properties and callbacks. But, when we mix React Native and native components, we need some special, cross-language mechanisms that would allow us to pass information between them. Properties are the simplest way of cross-component communication. So we need a way to pass properties both from native to React Native, and from React Native to native. In order to embed a React Native view in a native component, we use Opens the standard Android date picker dialog. Opens the standard Android date picker dialog. Opens the standard Android date picker dialog. The available keys for the Opens the standard Android date picker dialog. The available keys for the Returns a Promise which will be invoked an object containing Note the native date picker dialog has some UI glitches on Android 4 and lower
when using the A date has been selected. The dialog has been dismissed. Use Use To access the in-app developer menu: Hint To disable the developer menu for production builds: Run Selecting Using You can use These boxes only appear when you're running your app in dev mode. To debug the JavaScript code in Chrome, select In Chrome, press To debug on a real device: This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option: On To access the in-app developer menu: Hint To disable the developer menu for production builds: Run Selecting Using You can use By default, the warning box is enabled in Specific warnings can be ignored programmatically by setting the array: Strings in To debug the JavaScript code in Chrome, select In Chrome, press To debug on a real device: To use a custom JavaScript debugger define the This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option: On This should only be called from native code by sending the
-didUpdateDimensions event. @param {object} dims Simple string-keyed object of dimensions to set Initial dimensions are set before This should only be called from native code by sending the
+didUpdateDimensions event. @param {object} dims Simple string-keyed object of dimensions to set Initial dimensions are set before Note: Although dimensions are available immediately, they may change (e.g
due to device rotation) so any rendering logic or styles that depend on
these constants should try to call this function on every render, rather
@@ -21,6 +21,6 @@ setting a value in a Example: It is sometimes necessary to make changes directly to a component
+ It is sometimes necessary to make changes directly to a component
without using state/props to trigger a re-render of the entire subtree.
When using React in the browser for example, you sometimes need to
directly modify a DOM node, and the same is true for views in mobile
@@ -10,7 +10,7 @@ hierarchy and reconciling many views. TouchableOpacity
+and shouldComponentUpdate. TouchableOpacity
uses React component that wraps the platform React component that wraps the platform Example: Specifies the lock mode of the drawer. The drawer can be locked in 3 states:
+}, Specifies the background color of the drawer. The default value is white.
+If you want to set the opacity of the drawer, use rgba. Example: Specifies the lock mode of the drawer. The drawer can be locked in 3 states:
- unlocked (default), meaning that the drawer will respond (open/close) to touch gestures.
- locked-closed, meaning that the drawer will stay closed and not respond to gestures.
- locked-open, meaning that the drawer will stay opened and not respond to gestures.
@@ -33,7 +37,7 @@ from the edge of the window. The navigation view that will be rendered to the side of the screen and can be pulled in. Since React makes no assumptions about the rest of your technology stack, it's easily embeddable within an existing non-React Native app. In your app's You can find the latest version of the react-native library on Maven Central. Next, make sure you have the Internet permission in your This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to. You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an this._scrollSpring.setOvershootClampingEnabled(true) to change this.
See the below gif for an example of where in your interface you might
@@ -316,7 +326,7 @@ and hasn't been optimized with shouldComponentUpdate.AppRegistry #
Edit on GitHub AppRegistry is the JS entry point to running all React Native apps. App
+AppRegistry #
Edit on GitHub AppRegistry is the JS entry point to running all React Native apps. App
root components should register themselves with
AppRegistry.registerComponent, then the native system can load the bundle
for the app and then actually run the app when it's ready by invoking
@@ -6,7 +6,7 @@ for the app and then actually run the app when it's ready by invoking
AppRegistry.unmountApplicationComponentAtRootTag with the tag that was
pass into runApplication. These should always be used as a pair.AppRegistry should be required early in the require sequence to make
sure the JS execution environment is setup before other modules are
-required.Methods #
static registerConfig(config: Array<AppConfig>) #
static registerComponent(appKey: string, getComponentFunc: ComponentProvider) #
static registerRunnable(appKey: string, func: Function) #
static getAppKeys() #
static runApplication(appKey: string, appParameters: any) #
static unmountApplicationComponentAtRootTag(rootTag: number) #
AppState #
Edit on GitHub AppState can tell you if the app is in the foreground or background,
+AppState #
Edit on GitHub AppState can tell you if the app is in the foreground or background,
and notify you when the state changes.App States #
active - The app is running in the foregroundbackground - The app is running in the background. The user is either
in another app or on the home screeninactive - This is a transition state that currently never happens for
@@ -25,15 +25,16 @@ render: funct
);
},active state, and the null
-state will happen only momentarily.Methods #
Properties #
currentState: TypeCastExpression #
Examples #
Edit on GitHub Methods #
Properties #
currentState: TypeCastExpression #
Examples #
Edit on GitHub AppStateIOS #
Edit on GitHub AppStateIOS can tell you if the app is in the foreground or background,
+AppStateIOS #
Edit on GitHub AppStateIOS can tell you if the app is in the foreground or background,
and notify you when the state changes.iOS App States #
active - The app is running in the foregroundbackground - The app is running in the background. The user is either
in another app or on the home screeninactive - This is a state that occurs when transitioning between
@@ -26,18 +26,19 @@ render: funct
);
},active state, and the null
-state will happen only momentarily.Methods #
Properties #
currentState: TypeCastExpression #
Methods #
Properties #
currentState: TypeCastExpression #
Examples #
Edit on GitHub AsyncStorage #
Edit on GitHub AsyncStorage #
Edit on GitHub Promise object.Methods #
static getItem(key: string, callback?: ?(error: ?Error, result: ?string) => void) #
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) #
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) #
Promise object.static mergeItem(key: string, value: string, callback?: ?(error: ?Error) => void) #
Promise object.Methods #
static getItem(key, callback?) #
key and passes the result to callback, along with an Error if
+there is any. Returns a Promise object.static setItem(key, value, callback?) #
value for key and calls callback on completion, along with an
+Error if there is any. Returns a Promise object.static removeItem(key, callback?) #
Promise object.static mergeItem(key, value, callback?) #
Promise object. Not supported by all native implementations.static clear(callback?: ?(error: ?Error) => void) #
static clear(callback?) #
Promise object.static getAllKeys(callback?: ?(error: ?Error, keys: ?Array<string>) => void) #
Promise object.static flushGetRequests() #
static multiGet(keys: Array<string>, callback?: ?(errors: ?Array<Error>, result: ?Array<Array<string>>) => void) #
Promise object.static getAllKeys(callback?) #
Promise object.static flushGetRequests() #
static multiGet(keys, callback?) #
Promise object.Promise object.
let value = store[i][1];
});
});
-});static multiSet(keyValuePairs: Array<Array<string>>, callback?: ?(errors: ?Array<Error>) => void) #
Promise object.static multiRemove(keys: Array<string>, callback?: ?(errors: ?Array<Error>) => void) #
keys array. Returns a Promise object.static multiSet(keyValuePairs, callback?) #
Promise object.static multiRemove(keys, callback?) #
keys array. Returns a Promise object.static multiMerge(keyValuePairs: Array<Array<string>>, callback?: ?(errors: ?Array<Error>) => void) #
static multiMerge(keyValuePairs, callback?) #
Promise object.Properties #
Examples #
Edit on GitHub BackAndroid #
Edit on GitHub BackAndroid #
Edit on GitHub Methods #
CameraRoll #
Edit on GitHub CameraRoll provides access to the local camera roll / gallery.Methods #
static saveImageWithTag(tag) #
"file:///sdcard/img.png".static getPhotos(params: object) #
CameraRoll #
Edit on GitHub CameraRoll provides access to the local camera roll / gallery.Methods #
static saveImageWithTag(tag) #
"file:///sdcard/img.png".static getPhotos(params) #
getPhotosReturnChecker.getPhotosParamChecker.getPhotosReturnChecker.Examples #
Edit on GitHub Clipboard #
Edit on GitHub Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and AndroidMethods #
static getString() #
Promise, so you can use following code to get clipboard contentClipboard #
Edit on GitHub Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and AndroidMethods #
static getString() #
Promise, so you can use following code to get clipboard contentstatic setString(content: string) #
static setString(content) #
Examples #
Edit on GitHub Colors #
Edit on GitHub '#f0f' (#rgb)'#f0fc' (#rgba)'#ff00ff' (#rrggbb)'#ff00ff00' (#rrggbbaa)'rgb(255, 255, 255)''rgba(255, 255, 255, 1.0)''hsl(360, 100%, 100%)''hsla(360, 100%, 100%, 1.0)''transparent''red'0xff00ff00 (0xrrggbbaa)Colors #
Edit on GitHub '#f0f' (#rgb)'#f0fc' (#rgba)'#ff00ff' (#rrggbb)'#ff00ff00' (#rrggbbaa)'rgb(255, 255, 255)''rgba(255, 255, 255, 1.0)''hsl(360, 100%, 100%)''hsla(360, 100%, 100%, 1.0)''transparent''red'0xff00ff00 (0xrrggbbaa)Communication between native and React Native #
Edit on GitHub Introduction #
Properties #
Passing properties from native to React Native #
RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.RCTRootView has an initializer that allows you to pass arbitrary properties down to the React Native app. The initialProperties parameter has to be an instance of NSDictionary. The dictionary is internally converted into a JSON object that the top-level JS component can reference.Communication between native and React Native #
Edit on GitHub Introduction #
Properties #
Passing properties from native to React Native #
RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.RCTRootView has an initializer that allows you to pass arbitrary properties down to the React Native app. The initialProperties parameter has to be an instance of NSDictionary. The dictionary is internally converted into a JSON object that the top-level JS component can reference.DatePickerAndroid #
Edit on GitHub Example #
DatePickerAndroid #
Edit on GitHub Example #
Methods #
static open(options: Object) #
options object are:
+}Methods #
static open(options) #
options object are:
date (Date object or timestamp in milliseconds) - date to show by default
minDate (Date or timestamp in milliseconds) - minimum date that can be selected
* maxDate (Date object or timestamp in milliseconds) - minimum date that can be selectedaction, year, month (0-11),
@@ -18,13 +18,14 @@ still be resolved with action being DatePickerAndroid.dismissedActionAlways check whether the action before reading the values.minDate and maxDate options.static dateSetAction() #
static dismissedAction() #
Examples #
Edit on GitHub minDate and maxDate options.DatePickerIOS #
Edit on GitHub DatePickerIOS to render a date/time picker (selector) on iOS. This is
+DatePickerIOS #
Edit on GitHub DatePickerIOS to render a date/time picker (selector) on iOS. This is
a controlled component, so you must hook in to the onDateChange callback
and update the date prop in order for the component to update, otherwise
the user's change will be reverted immediately to reflect props.date as the
@@ -8,14 +8,15 @@ date and time.Examples #
Edit on GitHub Debugging #
Edit on GitHub Debugging React Native Apps #
control + ⌘ + z in the simulator.⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.Product → Scheme → Edit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.Android logging #
adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.Reload #
Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.YellowBox/RedBox #
console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.console.error to display a full screen error on a red background.Chrome Developer Tools #
Debug in Chrome from the developer menu. This will open a new tab at http://localhost:8081/debugger-ui.⌘ + option + i or select View → Developer → Developer Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.Live Reload #
Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.Dev Settings and select Auto reload on JS change optionFPS (Frames per Second) Monitor #
0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.Debugging #
Edit on GitHub Debugging React Native Apps #
control + ⌘ + z in the simulator.⌘ + m or F2 to simulate hardware menu button click). You can also install Frappé, a tool for OS X, which allows you to emulate shaking of devices remotely. You can use ⌘ + Shift + R as a shortcut to trigger a shake from Frappé.Product → Scheme → Edit Scheme... (or press ⌘ + <). Next, select Run from the menu on the left and change the Build Configuration to Release.assembleRelease task). Although this behavior can be customized by passing proper value to ReactInstanceManager#setUseDeveloperSupport.Android logging #
adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your Android app's logs.Reload #
Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.YellowBox/RedBox #
console.warn will display an on-screen log on a yellow background. Click on this warning to show more information about it full screen and/or dismiss the warning.console.error to display a full screen error on a red background.__DEV__. Set the following flag to disable it:console.ignoredYellowBox can be a prefix of the warning that should be ignored.Chrome Developer Tools #
Debug JS Remotely from the developer menu. This will open a new tab at http://localhost:8081/debugger-ui.⌘ + option + i or select View → Developer → Developer Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.adb command line tool to setup port forwarding from the device to your computer. For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.Custom JavaScript debugger #
REACT_DEBUGGER environment variable to a command that will start your custom debugger. That variable will be read from the Packager process. If that environment variable is set, selecting Debug JS Remotely from the developer menu will execute that command instead of opening Chrome. The exact command to be executed is the contents of the REACT_DEBUGGER environment variable followed by the space separated paths of all project roots (e.g. If you set REACT_DEBUGGER="node /path/to/launchDebugger.js --port 2345 --type ReactNative" then the command "node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app" will end up being executed). Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.Live Reload #
Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.Dev Settings and select Auto reload on JS change optionFPS (Frames per Second) Monitor #
0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.Dimensions #
Edit on GitHub Methods #
static set(dims: {[key:string]: any}) #
static get(dim: string) #
runApplication is called so they should
+Dimensions #
Edit on GitHub Methods #
static set(dims) #
static get(dim) #
runApplication is called so they should
be available before any other require's are run, but may be updated later.StyleSheet).var {height,
apiKey: '2c98749b4a1e588efec53b2acec13025',
indexName: 'react-native-versions',
inputSelector: '#algolia-doc-search',
- algoliaOptions: { facetFilters: [ "tags:0.24" ], hitsPerPage: 5 }
+ algoliaOptions: { facetFilters: [ "tags:0.25" ], hitsPerPage: 5 }
});
\ No newline at end of file
diff --git a/docs/direct-manipulation.html b/docs/direct-manipulation.html
index fa854ac7833..3b71320cdec 100644
--- a/docs/direct-manipulation.html
+++ b/docs/direct-manipulation.html
@@ -1,4 +1,4 @@
-Direct Manipulation #
Edit on GitHub Direct Manipulation #
Edit on GitHub setNativeProps is imperative
and stores state in the native layer (DOM, UIView, etc.) and not
within your React components, which makes your code more difficult to
reason about. Before you use it, try to solve your problem with setState
-and shouldComponentUpdate.setNativeProps with TouchableOpacity #
setNativeProps with TouchableOpacity #
setNativeProps internally to update the opacity of its child
component:setState instead of setNativeProps.DrawerLayoutAndroid #
Edit on GitHub DrawerLayout (Android only). The
+DrawerLayoutAndroid #
Edit on GitHub DrawerLayout (Android only). The
Drawer (typically used for navigation) is rendered with renderNavigationView
and direct children are the main view (where your content goes). The navigation
view is initially not visible on the screen, but can be pulled in from the
@@ -20,7 +20,11 @@ be set by the drawerWidth prop.Props #
drawerLockMode enum('unlocked', 'locked-closed', 'locked-open') #
Props #
drawerBackgroundColor color #
drawerLockMode enum('unlocked', 'locked-closed', 'locked-open') #
renderNavigationView function #
Integrating with Existing Apps #
Edit on GitHub Requirements #
Prepare your app #
build.gradle file add the React Native dependency:AndroidManifest.xml:Add native code #
Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.