diff --git a/docs/accessibility.html b/docs/accessibility.html index 55b5d51ea47..af22d8faacb 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,8 +1,44 @@ -
Accessibility on iOS encompasses many topics, but for many, accessibility is synonymous with VoiceOver, a technology available since iOS 3.0. It acts as a screen reader, allowing people with visual impairments to use their iOS devices. Click here to learn more.
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.
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:
Accessibility on iOS encompasses many topics, but for many, accessibility is synonymous with VoiceOver, a technology available since iOS 3.0. It acts as a screen reader, allowing people with visual impairments to use their iOS devices. Click here to learn more.
Accessibility on Android involves many diverse topics, one of which is enabling people with vision loss to use your application. For this community, Google provides a built-in screen reader service with Android called TalkBack. With TalkBack, you can use touch exploration and gestures to navigate a mobile device and application. TalkBack will read back the content on screen using text-to-speech and alert users to important notifications within your application. Click here to learn more about Android accessibility features and here to learn more about making your native applications accessible.
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:
In the above example, the accessibilityLabel on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.
Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by accessibilityTraits.
To use, set the accessibilityTraits property to one of (or an array of) accessibility trait strings:
Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.
Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an onMagicTap function, the system will traverse up the view hierarchy until it finds a view that does.
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.
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.
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.
Launches an alert dialog with the specified title and message.
Optionally provide a list of buttons. Tapping any button will fire the +
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
The last button in the list will be considered the 'Primary' button and it will appear bold.
This guide describes basic steps of the android development environment setup that are required to run React Native android apps on an android emulator. We don't discuss developer tool configuration such as IDEs here.
These instructions only cover installation "from scratch". If you happen to have some old, outdated version of Android SDK make sure to update required packages to the version mentioned below and install all the missing ones.
brew install android-sdk.~/.bashrc, ~/.zshrc or whatever your shell uses:android; in the window that appears make sure you check:android; in the window that appears make sure you check:

android avd and click on Create...
+
Start...Animations are an important part of modern UX, and the Animated
+
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
diff --git a/docs/animations.html b/docs/animations.html
index 146ec70c777..bdba5733dd1 100644
--- a/docs/animations.html
+++ b/docs/animations.html
@@ -1,4 +1,4 @@
-
Fluid, meaningful animations are essential to the mobile user experience. Like +
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
@@ -134,7 +134,7 @@ vertical panning.
The above API gives a powerful tool for expressing all s
concise, robust, and performant way. Check out more example code in
UIExplorer/AnimationExample. Of course there may still be times where Animated
doesn't support what you need, and the following sections cover other animation
-systems.
LayoutAnimation allows you to globally configure create and update
+systems.
LayoutAnimation allows you to globally configure create and update
animations that will be used for all views in the next render/layout cycle.
This is useful for doing flexbox layout updates without bothering to measure or
calculate specific properties in order to animate them directly, and is
diff --git a/docs/appregistry.html b/docs/appregistry.html
index f4d9edc7677..77b99adff65 100644
--- a/docs/appregistry.html
+++ b/docs/appregistry.html
@@ -1,4 +1,4 @@
-
AppRegistry is the JS entry point to running all React Native apps. App
+
AppRegistry is the JS entry point to running all React Native apps. App
root components should register themselves with
AppRegistry.registerComponent, then the native system can load the bundle
for the app and then actually run the app when it's ready by invoking
diff --git a/docs/appstateios.html b/docs/appstateios.html
index 26c94fa098b..23c065134be 100644
--- a/docs/appstateios.html
+++ b/docs/appstateios.html
@@ -1,4 +1,4 @@
-
AppStateIOS can tell you if the app is in the foreground or background,
+
AppStateIOS can tell you if the app is in the foreground or background,
and notify you when the state changes.
AppStateIOS is frequently used to determine the intent and proper behavior when handling push notifications.
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
diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html
index 25dffcdd00d..2c7ee115f27 100644
--- a/docs/asyncstorage.html
+++ b/docs/asyncstorage.html
@@ -1,4 +1,4 @@
-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 @@ -113,7 +113,7 @@ exports.examples : 'Basics - getItem, setItem, removeItem', render(): ReactElement { return <BasicStorageExample />; } }, -];
CameraRoll provides access to the local camera roll / gallery.
Saves the image to the camera roll / gallery.
@param {string} tag On Android, this is a local URI, such +
CameraRoll provides access to the local camera roll / gallery.
Saves the image to the camera roll / gallery.
@param {string} tag On Android, this is a local URI, such
as "file:///sdcard/img.png".
On iOS, the tag can be one of the following:
@param successCallback Invoked with the value of tag on success.
@param errorCallback Invoked with error message on error.
Invokes callback with photo identifier objects from the local camera
roll of the device matching shape defined by getPhotosReturnChecker.
@param {object} params See getPhotosParamChecker.
@param {function} callback Invoked with arg of shape defined by
getPhotosReturnChecker on success.
- @param {function} errorCallback Invoked with error message on error.
Use DatePickerIOS to render a date/time picker (selector) on iOS. This is
+
Use DatePickerIOS to render a date/time picker (selector) on iOS. This is
a controlled component, so you must hook in to the onDateChange callback
and update the date prop in order for the component to update, otherwise
the user's change will be reverted immediately to reflect props.date as the
@@ -158,7 +158,7 @@ exports.examples : '500',
fontSize: 14,
},
-});
To access the in-app developer menu, shake the iOS device or press control + ⌘ + z in the simulator.
Hint
To disable the developer menu for production builds, open your project in Xcode and select
Product→Scheme→Edit Scheme...(or press⌘ + <). Next, selectRunfrom the menu on the left and change the Build Configuration toRelease.
Selecting Reload or pressing ⌘ + r in the simulator will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets) or modified any Objective-C/Swift code, you will need to re-build from Xcode for the changes to take effect (you can do this with ⌘ + r in Xcode).
To debug the JavaScript code in Chrome, select Debug in Chrome from the developer menu. This will open a new tab at http://localhost:8081/debugger-ui.
Press ⌘ + option + i or select View → Developer → Developer Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.
To debug on a real device: Open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
Install the React Developer Tools extension for Google Chrome. This will allow you to navigate the component hierarchy via the React in the developer tools (see facebook/react-devtools for more information).
Select Enable Live Reload via the developer menu to have the application automatically reload when changes are made to the JavaScript.
On 0.5.0-rc and higher versions, you can enable a FPS graph overlay in the developers menu in order to help you debug performance problems.
To access the in-app developer menu:
control + ⌘ + z in the simulator.⌘ + m to simulate hardware menu button click)Hint
To disable the developer menu for production builds:
- For iOS open your project in Xcode and select
Product→Scheme→Edit Scheme...(or press⌘ + <). Next, selectRunfrom the menu on the left and change the Build Configuration toRelease.- For Android, by default, developer menu will be disabled in release builds done by gradle (e.g with gralde
assembleReleasetask). Although this behavior can be customized by passing proper value toReactInstanceManager#setUseDeveloperSupport.
Selecting Reload (or pressing ⌘ + r in the iOS simulator) will reload the JavaScript that powers your application. If you have added new resources (such as an image to Images.xcassets on iOS or to res/drawable folder on Android) or modified any native code (Objective-C/Swift code on iOS or Java/C++ code on Android), you will need to re-build the app for the changes to take effect.
To debug the JavaScript code in Chrome, select Debug in Chrome from the developer menu. This will open a new tab at http://localhost:8081/debugger-ui.
In Chrome, press ⌘ + option + i or select View → Developer → Developer Tools to toggle the developer tools console. Enable Pause On Caught Exceptions for a better debugging experience.
To debug on a real device:
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 8081 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.Install the React Developer Tools extension for Google Chrome. This will allow you to navigate the component hierarchy via the React in the developer tools (see facebook/react-devtools for more information).
This option allows for your JS changes to trigger automatic reload on the connected device/emulator. To enable this option:
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 optionOn 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.
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 diff --git a/docs/drawerlayoutandroid.html b/docs/drawerlayoutandroid.html new file mode 100644 index 00000000000..5a31ca945e0 --- /dev/null +++ b/docs/drawerlayoutandroid.html @@ -0,0 +1,37 @@ +
React component that wraps the platform DrawerLayout (Android only). The
+Drawer (typically used for navigation) is rendered with renderNavigationView
+and direct children are the main view (where your content goes). The navigation
+view is initially not visible on the screen, but can be pulled in from the
+side of the window specified by the drawerPosition prop and its width can
+be set by the drawerWidth prop.
Example:
Specifies the side of the screen from which the drawer will slide in.
Specifies the width of the drawer, more precisely the width of the view that be pulled in +from the edge of the window.
Determines whether the keyboard gets dismissed in response to a drag. + - 'none' (the default), drags do not dismiss the keyboard. + - 'on-drag', the keyboard is dismissed when a drag begins.
Function called whenever the navigation view has been closed.
Function called whenever the navigation view has been opened.
Function called whenever there is an interaction with the navigation view.
Function called when the drawer state has changed. The drawer can be in 3 states: +- idle, meaning there is no interaction with the navigation view happening at the time +- dragging, meaning there is currently an interation with the navigation view +- settling, meaning that there was an interaction with the navigation view, and the +navigation view is now finishing it's closing or opening animation
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 commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.
gem install cocoapodsnvm install iojs-v2 && nvm alias default iojs-v2, which installs the latest compatible version of io.js and sets up your terminal so that typing node runs io.js. With nvm you can install multiple versions of Node and io.js and easily switch between them.CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't installed CocoaPods yet, check out this tutorial.
When you are ready to work with CocoaPods, add the following line to Podfile. If you don't have one, then create it under the root directory of your project.
Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.
gem install cocoapodsnvm install iojs-v2 && nvm alias default iojs-v2, which installs the latest compatible version of io.js and sets up your terminal so that typing node runs io.js. With nvm you can install multiple versions of Node and io.js and easily switch between them.CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't installed CocoaPods yet, check out this tutorial.
When you are ready to work with CocoaPods, add the following line to Podfile. If you don't have one, then create it under the root directory of your project.
Remember to install all subspecs you need. The <Text> element cannot be used without pod 'React/RCTText'.
Then install your pods:
There are two pieces you’ll need to set up:
RCTRootView to display and manage your React Native componentsFirst, create a directory for your app’s React code and create a simple index.ios.js file:
Copy & paste following starter code for index.ios.js – it’s a barebones React Native app:
You need to include the NSLocationWhenInUseUsageDescription key
+
You need to include the NSLocationWhenInUseUsageDescription key
in Info.plist to enable geolocation. Geolocation is enabled by default
when you create a project with react-native init.
Geolocation follows the MDN specification: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
Invokes the success callback once with the latest location info. Supported diff --git a/docs/gesture-responder-system.html b/docs/gesture-responder-system.html index 50ff4574fd1..82c35799348 100644 --- a/docs/gesture-responder-system.html +++ b/docs/gesture-responder-system.html @@ -1,4 +1,4 @@ -
Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.
The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:
These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.
The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.
A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:
View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?If the View returns true and attempts to become the responder, one of the following will happen:
View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happeningView.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release itIf the view is responding, the following handlers can be called:
View.props.onResponderMove: (evt) => {} - The user is moving their fingerView.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows releaseView.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)evt is a synthetic touch event with the following form:
nativeEventchangedTouches - Array of all touch events that have changed since the last eventidentifier - The ID of the touchlocationX - The X position of the touch, relative to the elementlocationY - The Y position of the touch, relative to the elementpageX - The X position of the touch, relative to the screenpageY - The Y position of the touch, relative to the screentarget - The node id of the element receiving the touch eventtimestamp - A time identifier for the touch, useful for velocity calculationtouches - Array of all current touches on the screenonStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.
However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.
View.props.onStartShouldSetResponderCapture: (evt) => true,View.props.onMoveShouldSetResponderCapture: (evt) => true,For higher-level gesture interpretation, check out PanResponder.
Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.
The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:
These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.
The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.
A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:
View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?If the View returns true and attempts to become the responder, one of the following will happen:
View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happeningView.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release itIf the view is responding, the following handlers can be called:
View.props.onResponderMove: (evt) => {} - The user is moving their fingerView.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows releaseView.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)evt is a synthetic touch event with the following form:
nativeEventchangedTouches - Array of all touch events that have changed since the last eventidentifier - The ID of the touchlocationX - The X position of the touch, relative to the elementlocationY - The Y position of the touch, relative to the elementpageX - The X position of the touch, relative to the screenpageY - The Y position of the touch, relative to the screentarget - The node id of the element receiving the touch eventtimestamp - A time identifier for the touch, useful for velocity calculationtouches - Array of all current touches on the screenonStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.
However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.
View.props.onStartShouldSetResponderCapture: (evt) => true,View.props.onMoveShouldSetResponderCapture: (evt) => true,For higher-level gesture interpretation, check out PanResponder.
nvm install iojs-v2 && nvm alias default iojs-v2, which installs the latest compatible version of io.js and sets up your terminal so that typing node runs io.js. With nvm you can install multiple versions of Node and io.js and easily switch between them.brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.brew install flow. If you want to use flow.We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.
npm install -g react-native-clireact-native init AwesomeProjectIn the newly created folder AwesomeProject/
iOS/AwesomeProject.xcodeproj and hit run in Xcode.index.ios.js in your text editor of choice and edit some lines.Congratulations! You've successfully run and modified your first React Native app.
If you run into any issues getting started, see the troubleshooting page.
nvm install iojs-v2 && nvm alias default iojs-v2, which installs the latest compatible version of io.js and sets up your terminal so that typing node runs io.js. With nvm you can install multiple versions of Node and io.js and easily switch between them.brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.brew install flow. If you want to use flow.We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.
Xcode 6.3 or higher is required. It can be installed from the App Store.
To write React Native apps for Android, you will need to install the Android SDK (and an Android emulator if you want to work on your app without having to use a physical device). See Android setup guide for instructions on how to set up your Android environment.
To run the iOS app:
ios/AwesomeProject.xcodeproj and hit run in Xcode.index.ios.js in your text editor of choice and edit some lines.To run the Android app:
$ react-native run-androidindex.android.js in your text editor of choice and edit some lines.Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your app's logs
$ react-native run-android
index.android.js in your text editor of choice and edit some lines.adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your app's logsCongratulations! You've successfully run and modified your first React Native app.
If you run into any issues getting started, see the troubleshooting page.
If you already have a (iOS-only) React Native project and want to add Android support, you need to execute the following commands in your existing project directory:
react-native dependency in your package.json file to the latest version$ npm install$ react-native androidA React component for displaying different types of images, +
A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll.
Example usage:
When your entire codebase respects this convention, you're able to do interesting things like automatically packaging the assets that are being used in your app. Note that in the current form, nothing is enforced, but it will be in the future.

NOTE: App build required for new resources
Any time you add a new resource to
Images.xcassetsyou will need to re-build your app through Xcode before you can use it - a reload from within the simulator is not enough.
This process is currently being improved, a much better workflow will be -available shortly.
Many of the images you will display in your app will not be available at compile time, or you will want to load some dynamically to keep the binary size down. Unlike with static resources, you will need to manually specify the dimensions of your image.
When your entire codebase respects this convention, you're able to do interesting things like automatically packaging the assets that are being used in your app. Note that in the current form, nothing is enforced, but it will be in the future.

NOTE: App build required for new resources
Any time you add a new resource to
Images.xcassetsyou will need to re-build your app through Xcode before you can use it - a reload from within the simulator is not enough.
This process is currently being improved, a much better workflow will be available shortly.
Add your images as bitmap drawables to the android project (<yourapp>/android/app/src/main/res). To provide different resolutions of your assets, check out using configuration qualifiers. Normally, you will want to put your assets in the following directories (create them under res if they don't exist):
drawable-mdpi (1x)drawable-hdpi (1.5x)drawable-xhdpi (2x)drawable-xxhdpi (3x)If you're missing a resolution for your asset, Android will take the next best thing and resize it for you.
NOTE: App build required for new resources
Any time you add a new resource to your drawables you will need to re-build your app by running
react-native run-androidbefore you can use it - reloading the JS is not enough.
This process is currently being improved, a much better workflow will be available shortly.
Many of the images you will display in your app will not be available at compile time, or you will want to load some dynamically to keep the binary size down. Unlike with static resources, you will need to manually specify the dimensions of your image.
InteractionManager allows long-running work to be scheduled after any +
InteractionManager allows long-running work to be scheduled after any interactions/animations have completed. In particular, this allows JavaScript animations to run smoothly.
Applications can schedule tasks to run after interactions with the following:
When using React Native, you're going to be running your JavaScript code in two environments:
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.
Syntax transformers make writing code more enjoyable by allowing you to use new JavaScript syntax without having to wait for support on all interpreters.
As of version 0.5.0, React Native ships with the Babel JavaScript compiler. Check Babel documentation on its supported transformations for more details.
Here's a full list of React Native's enabled transformations.
ES5
promise.catch(function() { });ES6
<C onPress={() => this.setState({pressed: true})}Math.max(...array);class C extends React.Component { render() { return <View />; } }var {isActive, style} = this.props;var key = 'abc'; var obj = {[key]: 10};var obj = { method() { return 10; } };var name = 'vjeux'; var obj = { name };function(type, ...args) { }var who = 'world'; var str = `Hello ${who}`;ES7
var extended = { ...obj, a: 10 };function f(a, b, c,) { }When using React Native, you're going to be running your JavaScript code in two environments:
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.
Syntax transformers make writing code more enjoyable by allowing you to use new JavaScript syntax without having to wait for support on all interpreters.
As of version 0.5.0, React Native ships with the Babel JavaScript compiler. Check Babel documentation on its supported transformations for more details.
Here's a full list of React Native's enabled transformations.
ES5
promise.catch(function() { });ES6
<C onPress={() => this.setState({pressed: true})}Math.max(...array);class C extends React.Component { render() { return <View />; } }var {isActive, style} = this.props;var key = 'abc'; var obj = {[key]: 10};var obj = { method() { return 10; } };var name = 'vjeux'; var obj = { name };function(type, ...args) { }var who = 'world'; var str = `Hello ${who}`;ES7
var extended = { ...obj, a: 10 };function f(a, b, c,) { }This is an initial release of React Native Android and therefore not all of the views present on iOS are released on Android. We are very much interested in the communities' feedback on the next set of modules and views for Open Source. Not all native views between iOS and Android have a 100% equivalent representation, here it will be necessary to use a counterpart eg using ProgressBar on Android in place of ActivityIndicator on iOS.
Our provisional plan for common views and modules includes:
Views
Modules
There is currently no easy way of publishing custom native modules on Android. Smooth work flow for contributors is important and this will be looked at very closely after the initial Open Source release. Of course the aim will be to streamline and optimize the process between iOS and Android as much as possible.
There is a noted difference in the handling of Views with an opacity of 0 between iOS and Android. While iOS will allow these views to be clicked through and the View below will receive the touch input, for Android the touch will be blocked. This can be demonstrated in this example where it will only be possible to click the touchable on iOS.
An optimization feature of the Android version of React Native is for views which only contribute to the layout to not have a native view, only their layout properties are propagated to their children views. This optimization is to provide stability in deep view hierarchies for React Native and is therefore enabled by default. Should you depend on a view being present or internal tests incorrectly detect a view is layout only it will be necessary to turn off this behavior. To do this, set collapsable to false as in this example:
Automatically animates views to their new positions when the +
Automatically animates views to their new positions when the next layout happens.
A common way to use this API is to call LayoutAnimation.configureNext
before calling setState.
Schedules an animation to happen on the next layout.
@param config Specifies animation properties:
duration in millisecondscreate, config for animating in new views (see Anim type)update, config for animating views that have been updated
(see Anim type)@param onAnimationDidEnd Called when the animation finished. diff --git a/docs/linking-libraries-ios.html b/docs/linking-libraries-ios.html index a7b608b730d..bfcd0bd7854 100644 --- a/docs/linking-libraries-ios.html +++ b/docs/linking-libraries-ios.html @@ -1,4 +1,4 @@ -
Not every app uses all the native capabilities, and including the code to support +
Not every app uses all the native capabilities, and including the code to support all those features would impact the binary size... But we still want to make it easy to add these features whenever you need them.
With that in mind we exposed many of these features as independent static libraries.
For most of the libs it will be as simple as dragging two files, sometimes a third step will be necessary, but no more than that.
All the libraries we ship with React Native live on the If your app was launched from an external url registered to your app you can
access and handle it from any component you want with ListView - A core component designed for efficient display of vertically
+ ListView - A core component designed for efficient display of vertically
scrolling lists of changing data. The minimal API is to create a
Map annotations with title/subtitle. Insets for the map's legal label, originally at bottom left of the map.
+ Map annotations with title/subtitle. Insets for the map's legal label, originally at bottom left of the map.
See The map type to be displayed. Maximum size of area that can be displayed. Minimum size of area that can be displayed. Callback that is called once, when the user is clicked on a annotation. Callback that is called continuously when the user is dragging the map. Callback that is called once, when the user is done moving the map. When this property is set to 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 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 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 These subclasses are essentially singletons - only one instance of each is created by the bridge. They vend native views to the Vending a view is simple: In this example we create view manager class Properties that are to be reflected in JavaScript are annotated with Views are created in the Setting properties on a view is not handled by automatically calling setter methods as it is on iOS; for Android, you manually invoke the setters via the The final Java step is to register the ViewManager to the application, this happens in a similar way to Native Modules, via the applications package member function The very final step is to create the JavaScript module that defines the interface layer between Java and JavaScript for the users of your new view. Much of the effort is handled by internal React code in Java and JavaScript and all that is left for you is to describe the So now we know how to expose native view components that we can control easily from JS, but how do we deal with events from the user, like pinch-zooms or panning? When a native event occurs the native code should issue an event to the JavaScript representation of the View, and the two views are linked with the value returned from the The event name 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 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 Let's say we want to add an interactive Map to our app - might as well use Native views are created and manipulated by subclasses of Vending a view is simple: 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 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 Let's say we want to add an interactive Map to our app - might as well use Native views are created and manipulated by subclasses of Vending a view is simple: 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 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. 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 An optional method called To expose a method to JavaScript a Java method must be annotated using The following argument types are supported for methods annotated with The last step within Java is to register the Module; this happens in the The package needs to be provided to the ReactInstanceManager when it is built. See To make it simpler for to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of Now, from your JavaScript file you can call the method like this: Native modules also support a special kind of argument - a callback. In most cases it is used to provide the function call result to JavaScript. This method would be accessed in JavaScript using: A native module is supposed to invoke its callback only once. It can, however, store the callback and invoke it later. It is very important to highlight that the callback is not invoked immediately after the native function completes - remember that bridge communication is asynchronous, and this too is tied to the run loop. Native modules should not have any assumptions about what thread they are being called on, as the current assignment is subject to change in the future. If a blocking call is required, the heavy work should be dispatched to an internally managed worker thread, and any callbacks distributed from there. Native modules can signal events to JavaScript without being invoked directly. The easiest way to do this is to use the JavaScript modules can then register to receive events by 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). 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 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). 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 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 You can also use The differences between Navigator
+ The differences between Navigator
and NavigatorIOS are a common
source of confusion for newcomers. Both For most non-trivial apps, you will want to use Use Use To change the animation or gesture properties of the scene, provide a
diff --git a/docs/navigatorios.html b/docs/navigatorios.html
index b799099f3e8..ff8eceb6d91 100644
--- a/docs/navigatorios.html
+++ b/docs/navigatorios.html
@@ -1,4 +1,4 @@
- NavigatorIOS wraps UIKit navigation and allows you to add back-swipe
+ NavigatorIOS wraps UIKit navigation and allows you to add back-swipe
functionality across your app. A route is an object used to describe each page in the navigator. The first
route is provided to NavigatorIOS as Libraries folder in
diff --git a/docs/linkingios.html b/docs/linkingios.html
index f4c4aacdb59..16f73a7f2e3 100644
--- a/docs/linkingios.html
+++ b/docs/linkingios.html
@@ -1,4 +1,4 @@
-LinkingIOS
LinkingIOS gives you a general interface to interact with both, incoming
+LinkingIOS
LinkingIOS gives you a general interface to interact with both, incoming
and outgoing app links.Basic Usage #
Handling deep links #
ListView
ListView
ListView.DataSource, populate it with a simple array of data blobs, and
instantiate a ListView component with that data source and a renderRow
diff --git a/docs/mapview.html b/docs/mapview.html
index 30e4c031380..37d0911e9d3 100644
--- a/docs/mapview.html
+++ b/docs/mapview.html
@@ -1,4 +1,4 @@
-MapView
Edit on GitHubProps #
annotations [{latitude: number, longitude: number, animateDrop: bool, title: string, subtitle: string, hasLeftCallout: bool, hasRightCallout: bool, onLeftCalloutPress: function, onRightCalloutPress: function, id: string}] #
legalLabelInsets {top: number, left: number, bottom: number, right: number} #
MapView
Edit on GitHubProps #
annotations [{latitude: number, longitude: number, animateDrop: bool, title: string, subtitle: string, hasLeftCallout: bool, hasRightCallout: bool, onLeftCalloutPress: function, onRightCalloutPress: function, id: string}] #
legalLabelInsets {top: number, left: number, bottom: number, right: number} #
EdgeInsetsPropType.js for more information.mapType enum('standard', 'satellite', 'hybrid') #
maxDelta number #
minDelta number #
onAnnotationPress function #
onRegionChange function #
onRegionChangeComplete function #
pitchEnabled bool #
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
diff --git a/docs/modal.html b/docs/modal.html
index 30f3798c8b3..2fe5534f91e 100644
--- a/docs/modal.html
+++ b/docs/modal.html
@@ -1,4 +1,4 @@
-Modal
Edit on GitHubProps #
Edit on GitHubExamples #
Modal
Edit on GitHubProps #
Edit on GitHubExamples #
Native UI Components (Android)
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.ImageViewcomponent available in the core React Native library.ImageView example #
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. An example of when you would use ViewManager instead is when wrapping a component with FrameLayout, such as ProgressBar.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.@UIPropcreateViewInstance methodupdateView methodcreateViewManagers of the applications package.1. Create the
ViewManager subclass #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.2. Annotate the view properties #
@UIProp. The types currently supported are BOOLEAN, NUMBER, STRING, MAP and ARRAY. Each property is declared as a public static final String and its assigned value will be the name of the property in JavaScript.3. Implement method
createViewInstance #createViewInstance method, the view should initialize itself in its default state, any properties will be set via a follow up call to updateView.4. Implement method
updateView #updateView of your ViewManager. Values are fetched from the CatalystStylesDiffMap and dispatched to the View instance as required. It is up to a combination of updateView and the View class to check the validity of the properties and behave accordingly.5. Register the
ViewManager #createViewManagers.6. Implement the JavaScript module #
propTypes.requireNativeComponent commonly takes two parameters, the first is the name of the native view and the second is an object that describes the component interface. The component interface should declare a friendly name for use in debug messages and must declare the propTypes reflected by the Native View. The propTypes are used for checking the validity of a user's use of the native view.Events #
getId() method.topChange maps to the onChange callback prop in JavaScript (mappings are in UIManagerModuleConstants.java). This callback is invoked with the raw event, which we typically process in the wrapper component to make a simpler API:Native UI Components (iOS)
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.MapView component available in the core React Native library.iOS MapView example #
MKMapView, we just need to make it usable from JavaScript.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.RCT_EXPORT_MODULE() marker macro.-(UIView *)view methodNative UI Components (iOS)
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.MapView component available in the core React Native library.iOS MapView example #
MKMapView, we just need to make it usable from JavaScript.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.RCT_EXPORT_MODULE() marker macro.-(UIView *)view methodRCTMapManager and other components in the source code.Native Modules (Android)
The Toast Module #
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.ReactContextBaseJavaModule requires that a method called getName is implemented. The purpose of this method is to return the string name of the NativeModule which represents this class in JavaScript. So here we will call this ToastAndroid so that we can access it through React.NativeModules.ToastAndroid in JavaScript.getConstants returns the constant values exposed to JavaScript. Its implementation is not required but is very useful to key pre-defined values that need to be communicated from JavaScript to Java in sync.@ReactMethod. The return type of bridge methods is always void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).Argument Types #
@ReactMethod and they directly map to their JavaScript equivalentsRegister the Module #
createNativeModules of your apps package. If a module is not registered it will not be available from JavaScript.UIExplorerActivity.java for an example. The default package when you initialize a new project is MainReactPackage.java.NativeModules each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.Beyond Toasts #
Callbacks #
Threading #
Sending Events to JavaScript #
RCTDeviceEventEmitter which can be obtained from the ReactContext as in the code snippet below.addListenerOn using the Subscribable mixinNative Modules (iOS)
iOS Calendar Module Example #
RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.Native Modules (iOS)
iOS Calendar Module Example #
RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.File>New File menu option. You will need to import RCTBridgeModule.h in this header file.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.Navigator Comparison
Navigator Comparison
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 #
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.NavigatorIOS.navigationBar prop.NavigatorIOS #
Navigator in its current form.Navigator - it won't be long before you run into issues when trying to do anything complex with NavigatorIOS.Navigator
Navigator to transition between different scenes in your app. To
+Navigator
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.NavigatorIOS
NavigatorIOS
Routes #
initialRoute: