diff --git a/docs/activityindicatorios.html b/docs/activityindicatorios.html index 6354fafe8c5..5a094a35673 100644 --- a/docs/activityindicatorios.html +++ b/docs/activityindicatorios.html @@ -1,12 +1,11 @@ -
All rights reserved.
This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.
@flow
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
-AppRegistry.runApplication.
AppRegistry should be required early in the require sequence to make
-sure the JS execution environment is setup before other modules are
-required.
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
- typical React Native apps.For more information, see -Apple's documentation
To see the current state, you can check AppStateIOS.currentState, which
-will be kept up-to-date. However, currentState will be null at launch
-while AppStateIOS retrieves it over the bridge.
This example will only ever appear to say "Current state is: active" because
-the app is only visible to the user when in the active state, and the null
-state will happen only momentarily.
AsyncStorage is a simple, asynchronous, persistent, global, key-value storage -system. 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 facad over the native iOS implementation to provide -a clear JS API, real Error objects, and simple non-multi functions.
Fetches key and passes the result to callback, along with an Error if
-there is any.
Sets value for key and calls callback on completion, along with an
-Error if there is any.
Merges existing value with input value, assuming they are stringified json.
Not supported by all native implementations.
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.
Gets all keys known to the system, for all callers, libraries, etc.
multiGet invokes callback with an array of key-value pair arrays that -matches the input format of multiSet.
multiGet(['k1', 'k2'], cb) -> cb([['k1', 'val1'], ['k2', 'val2']])
multiSet and multiMerge take arrays of key-value array pairs that match -the output of multiGet, e.g.
multiSet([['k1', 'val1'], ['k2', 'val2']], cb);
Delete all the keys in the keys array.
Merges existing values with input values, assuming they are stringified -json.
Not supported by all native implementations.
All rights reserved.
This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.
@flow
Saves the image with tag tag to the camera roll.
@param {string} tag - Can be any of the three kinds of tags we accept: - 1. URL - 2. assets-library tag - 3. tag returned from storing an image in memory
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
-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
-source of truth.
The currently selected date.
Maximum date.
Restricts the range of possible date/time values.
Minimum date.
Restricts the range of possible date/time values.
The interval at which minutes can be selected.
The date picker mode.
Date change handler.
This is called when the user changes the date or time in the UI. -The first and only argument is a Date object representing the new -date and time.
Timezone offset in minutes.
By default, the date picker will use the device's timezone. With this -parameter, it is possible to force a certain timezone offset. For -instance, to show times in Pacific Standard Time, pass -7 * 60.
To debug the javascript code of your react app do the following:
Command + D and a webpage should open up at http://localhost:8081/debugger-ui. (Chrome only for now)Command + Option + I to open the Chrome Developer tools, or open it via View -> Developer -> Developer Tools.Install the React Developer Tools extension for Google Chrome. This will allow you to navigate the view hierarchy if you select the React tab when the developer tools are open.
To activate Live Reload do the following:
Control + Command + Z.Enable/Disable Live Reload, Reload and Enable/Disable Debugging options./!\ ATTENTION /!\ -You need to add NSLocationWhenInUseUsageDescription key -in Info.plist to enable geolocation, otherwise it's going -to fail silently! -!/ !/
Geolocation follows the MDN specification: -https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
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.
brew install node. New to node or npm?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.npm install -g react-native-clireact-native init AwesomeProjectIn the newly created folder AwesomeProject/
AwesomeProject.xcodeproj and hit run in Xcodeindex.ios.js in your text editor of choice and edit some linesCongratulations! You've just successfully run and modified your first React Native app.
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:
accessibilityLabel - Custom string to display for accessibility.
accessible - Whether this element should be revealed as an accessible -element.
capInsets - When the image is resized, the corners of the size specified -by capInsets will stay a fixed size, but the center content and borders -of the image will be stretched. This is useful for creating resizable -rounded buttons, shadows, and other resizable assets. More info:
testID - A unique identifier for this element to be used in UI Automation -testing scripts.
Displaying images is a fascinating subject, React Native uses some cool tricks to make it a better experience.
If you don't give a size to an image, the browser is going to render a 0x0 element, download the image, and then render the image based with the correct size. The big issue with this behavior is that your UI is going to jump all around as images load, this makes for a very bad user experience.
In React Native, this behavior is intentionally not implemented. It is more work for the developer to know the dimensions (or just aspect ratio) of the image in advance, but we believe that it leads to a better user experience.
A common feature request from developers familiar with the web is background-image. To handle this use case, simply create a normal <Image> component and add whatever children to it you would like to layer on top of it.
Image decoding can take more than a frame-worth of time. This is one of the major source of frame drops on the web because decoding is done in the main thread. In React Native, image decoding is done in a different thread. In practice, you already need to handle the case when the image is not downloaded yet, so displaying the placeholder for a few more frames while it is decoding does not require any code change.
In the course of a project, it is not uncommon to add and remove many images and accidentally end up shipping images you are no longer using in the app. In order to fight this, we need to find a way to know statically which images are being used in the app. To do that, we introduced a marker on require. The only allowed way to refer to an image in the bundle is to literally write require('image!name-of-the-asset') in the source.
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.
iOS saves multiple sizes for the same image in your Camera Roll, it is very important to pick the one that's as close as possible for performance reasons. You wouldn't want to use the full quality 3264x2448 image as source when displaying a 200x200 thumbnail. If there's an exact match, React Native will pick it, otherwise it's going to use the first one that's at least 50% bigger in order to avoid blur when resizing from a close size. All of this is done by default so you don't have to worry about writing the tedious (and error prone) code to do it yourself.
In React Native, one interesting decision is that the src attribute is named source and doesn't take a string but an object with an uri attribute.
On the infrastructure side, the reason is that it allows to attach metadata to this object. For example if you are using require('image!icon'), then we add an isStatic attribute to flag it as a local file (don't rely on this fact, it's likely to change in the future!). This is also future proofing, for example we may want to support sprites at some point, instead of outputting {uri: ...}, we can output {uri: ..., crop: {left: 10, top: 50, width: 20, height: 40}} and transparently support spriting on all the existing call sites.
On the user side, this lets you annotate the object with useful attributes such as the dimension of the image in order to compute the size it's going to be displayed in. Feel free to use it as your data structure to store more information about your image.
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:
Compare this to other scheduling alternatives:
The touch handling system considers one or more active touches to be an
-'interaction' and will delay runAfterInteractions() callbacks until all
-touches have ended or been cancelled.
InteractionManager also allows applications to register animations by -creating an interaction 'handle' on animation start, and clearing it upon -completion:
All rights reserved.
This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.
@flow
Not every app uses all the native capabilities, and including the code to support -all those features would impact in the binary size... But we still want to make -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 simples as dragging two files, sometimes a third -step will be necessary, but no more than that.
All the libraries we ship with React Native live on the Libraries folder in
-the root of the repository. Some of them are pure JavaScript, and you just need
-to require it. Other libraries also rely on some native code, in that case
-you'll have to add these files to your app, otherwise the app will throw an
-error as soon as you try to use the library.
If the library has native code, there must be a .xcodeproj file inside it's
-folder.
-Drag this file to your project on Xcode (usually under the Libaries group
-on Xcode);

Click on your main project file (the one that represents the .xcodeproj)
-select Build Phases and drag the static library from the Products folder
-insed the Library you are importing to Link Binary With Libraries

Not every library will need this step, what you need to consider is:
Do I need to know the contents of the library at compile time?
What that means is, are you using this library on the native site or just in -JavaScript? If you are just using it in JavaScript, you are good to go!
This step is not necessary for all libraries that we ship we React Native but
-PushNotificationIOS and LinkingIOS.
In the case of the PushNotificationIOS for example, you have to call a method
-on the library from your AppDelegate every time a new push notifiation is
-received.
For that we need to know the library's headers. To achieve that you have to go
-to your project's file, select Build Settings and search for Header Search
-Paths. There you should include the path to you library (if it has relevant
-files on subdirectories remember to make it recursive, like React on the
-example).

All rights reserved.
This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.
@flow
ListView - A core component designed for efficient display of vertically
-scrolling lists of changing data. The minimal API is to create a
-ListView.DataSource, populate it with a simple array of data blobs, and
-instantiate a ListView component with that data source and a renderRow
-callback which takes a blob from the data array and returns a renderable
-component.
Minimal example:
ListView also supports more advanced features, including sections with sticky
-section headers, header and footer support, callbacks on reaching the end of
-the available data (onEndReached) and on the set of rows that are visible
-in the device viewport change (onChangeVisibleRows), and several
-performance optimizations.
There are a few performance operations designed to make ListView scroll -smoothly while dynamically loading potentially very large (or conceptually -infinite) data sets:
Only re-render changed rows - the hasRowChanged function provided to the -data source tells the ListView if it needs to re-render a row because the -source data has changed - see ListViewDataSource for more details.
Rate-limited row rendering - By default, only one row is rendered per
-event-loop (customizable with the pageSize prop). This breaks up the
-work into smaller chunks to reduce the chance of dropping frames while
-rendering rows.
How many rows to render on initial component mount. Use this to make -it so that the first screen worth of data apears at one time instead of -over the course of multiple frames.
(visibleRows, changedRows) => void
Called when the set of visible rows changes. visibleRows maps
-{ sectionID: { rowID: true }} for all the visible rows, and
-changedRows maps { sectionID: { rowID: true | false }} for the rows
-that have changed their visibility, with true indicating visible, and
-false indicating the view has moved out of view.
Called when all rows have been rendered and the list has been scrolled -to within onEndReachedThreshold of the bottom. The native scroll -event is provided.
Threshold in pixels for onEndReached.
Number of rows to render per event loop.
An experimental performance optimization for improving scroll perf of -large lists, used in conjunction with overflow: 'hidden' on the row -containers. Use at your own risk.
() => renderable
The header and footer are always rendered (if these props are provided) -on every render pass. If they are expensive to re-render, wrap them -in StaticContainer or other mechanism as appropriate. Footer is always -at the bottom of the list, and header at the top, on every render pass.
(rowData, sectionID, rowID) => renderable -Takes a data entry from the data source and its ids and should return -a renderable component to be rendered as the row. By default the data -is exactly what was put into the data source, but it's also possible to -provide custom extractors.
(sectionData, sectionID) => renderable
If provided, a sticky header is rendered for this section. The sticky -behavior means that it will scroll with the content at the top of the -section until it reaches the top of the screen, at which point it will -stick to the top until it is pushed off the screen by the next section -header.
How early to start rendering rows before they come on screen, in -pixels.
Insets for the map's legal label, originally at bottom left of the map.
-See EdgeInsetsPropType.js for more information.
Maximum size of area that can be displayed.
Minimum size of area that can be displayed.
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 true and a valid camera is associated
-with the map, the camera’s pitch angle is used to tilt the plane
-of the map. When this property is set to false, the camera’s pitch
-angle is ignored and the map is always displayed as if the user
-is looking straight down onto it.
The region to be displayed by the map.
The region is defined by the center coordinates and the span of -coordinates to display.
When this property is set to true and a valid camera is associated with
-the map, the camera’s heading angle is used to rotate the plane of the
-map around its center point. When this property is set to false, the
-camera’s heading angle is ignored and the map is always oriented so
-that true north is situated at the top of the map view
If false the user won't be able to change the map region being displayed.
-Default value is true.
If true the app will ask for the user's location and focus on it.
-Default value is false.
NOTE: You need to add NSLocationWhenInUseUsageDescription key in -Info.plist to enable geolocation, otherwise it is going -to fail silently!
Used to style and layout the MapView. See StyleSheet.js and
-ViewStylePropTypes.js for more info.
If false the user won't be able to pinch/zoom the map.
-Default value is true.
Sometimes an app needs access to platform API, and React Native doesn't have a corresponding wrapper yet. Maybe you want to reuse some existing Objective-C or C++ code without having to reimplement it in JavaScript. Or write some high performance, multi-threaded code such as image processing, network stack, database or rendering.
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 (Swift is not supported yet) and core libraries (Foundation, UIKit).
This guide will use iOS Calendar API example. Let's say we would like to be able to access iOS calendar from JavaScript.
Native module is just an Objectve-C class that implements RCTBridgeModule protocol. If you are wondering, RCT is a shorthand for ReaCT.
React Native will not expose any methods of CalendarManager to JavaScript unless explicitly asked. Fortunately this is pretty easy with RCT_EXPORT:
Now from your JavaScript file you can call the method like this:
Notice that the exported method name was generated from first part of Objective-C selector. Sometimes it results in a non-idiomatic JavaScript name (like the one in our example). You can change the name by supplying an optional argument to RCT_EXPORT, e.g. RCT_EXPORT(addEvent).
The return type of the method should always be void. React Native bridge is asynchronous, so the only way to pass result to JavaScript is by using callbacks or emitting events (see below).
React Native supports several types of arguments that can be passed from JavaScript code to native module:
NSString)NSInteger, float, double, CGFloat, NSNumber)BOOL, NSNumber)NSArray) of any types from this listNSDictionary) with string keys and values of any type from this listRCTResponseSenderBlock)In our CalendarManager example, if we want to pass event date to native, we have to convert it to a string or a number:
As CalendarManager.addEvent method gets more and more complex, the number of arguments will grow. Some of them might be optional. In this case it's worth considering changing the API a little bit to accept a dictionary of event attributes, like this:
and call it from JavaScript:
NOTE: About array and map
React Native doesn't provide any guarantees about the types of values in these structures. Your native module might expect array of strings, but if JavaScript calls your method with an array that contains number and string you'll get
NSArraywithNSNumberandNSString. It's developer's responsibility to check array/map values types (seeRCTConvertfor helper methods).
WARNING
This section is even more experimental than others, we don't have a set of best practices around callbacks yet.
Native module also supports a special kind of argument - callback. In most cases it is used to provide function call result to JavaScript.
RCTResponseSenderBlock accepts only one argument - array of arguments to pass to JavaScript callback. In this case we use node's convention to set first argument to error and the rest - to the result of the function.
Native module is supposed to invoke callback only once. It can, however, store the callback as an ivar and invoke it later. This pattern is often used to wrap iOS APIs that require delegate. See RCTAlertManager.
If you want to pass error-like object to JavaScript, use RCTMakeError from RCTUtils.h.
The native module should not have any assumptions about what thread it is being called on. React Native invokes native modules methods on a separate serial GCD queue, but this is an implementation detail and might change. If the native module needs to call main-thread-only iOS API, it should schedule the operation on the main queue:
The same way if the operation can take a long time to complete, the native module should not block. It is a good idea to use dispatch_async to schedule expensive work on background queue.
Native module can export constants that are instantly available to JavaScript at runtime. This is useful to export some initial data that would otherwise require a bridge round-trip.
JavaScript can use this value right away:
Note that the constants are exported only at initialization time, so if you change constantsToExport value at runtime it won't affect JavaScript environment.
The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use eventDispatcher:
JavaScript code can subscribe to these events:
For more examples of sending events to JavaScript, see RCTLocationObserver.
Use Navigator to transition between different scenes in your app. To
-accomplish this, provide route objects to the navigator to identify each
-scene, and also a renderScene function that the navigator can use to
-render the scene for a given route.
To change the animation or gesture properties of the scene, provide a
-configureScene prop to get the config object for a given route. See
-Navigator.SceneConfigs for default animations and more info on
-scene config options.
Navigator can be told to navigate in two ways. If you have a ref to
-the element, you can invoke several methods on it to trigger navigation:
jumpBack() - Jump backward without unmounting the current scenejumpForward() - Jump forward to the next scene in the route stackjumpTo(route) - Transition to an existing scene without unmountingpush(route) - Navigate forward to a new scene, squashing any scenes
- that you could jumpForward topop() - Transition back and unmount the current scenereplace(route) - Replace the current scene with a new routereplaceAtIndex(route, index) - Replace a scene as specified by an indexreplacePrevious(route) - Replace the previous sceneimmediatelyResetRouteStack(routeStack) - Reset every scene with an
- array of routespopToRoute(route) - Pop to a particular scene, as specified by it's
- route. All scenes after it will be unmountedpopToTop() - Pop to the first scene in the stack, unmounting every
- other sceneThe navigator object is made available to scenes through the renderScene
-function. The object has all of the navigation methods on it, as well as a
-few utilities:
parentNavigator - a refrence to the parent navigator object that was
- passed in through props.navigatoronWillFocus - used to pass a navigation focus event up to the parent
- navigatoronDidFocus - used to pass a navigation focus event up to the parent
- navigatorOptional function that allows configuration about scene animations and -gestures. Will be invoked with the route and should return a scene -configuration object
Provide a single "route" to start on. A route is an arbitrary object -that the navigator will use to identify each scene before rendering. -Either initialRoute or initialRouteStack is required.
Provide a set of routes to initially mount the scenes for. Required if no -initialRoute is provided
Optionally provide a navigation bar that persists across scene -transitions
Optionally provide the navigator object from a parent Navigator
Will be called with the new route of each scene after the transition is -complete or after the initial mounting. This overrides the onDidFocus -handler that would be found in this.props.navigator
Will be called with (ref, indexInStack) when the scene ref changes
Will emit the target route upon mounting and before each nav transition, -overriding the handler in this.props.navigator. This overrides the onDidFocus -handler that would be found in this.props.navigator
Required function which renders the scene for a given route. Will be -invoked with the route, the navigator object, and a ref handler that -will allow a ref to your scene to be provided by props.onItemRef
Styles to apply to the container of each scene
Should the backstack back button "jump" back instead of pop? Set to true -if a jump forward might happen after the android back button is pressed, -so the scenes will remain mounted
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 initialRoute:
Now MyView will be rendered by the navigator. It will recieve the route
-object in the route prop, a navigator, and all of the props specified in
-passProps.
See the initialRoute propType for a complete definition of a route.
A navigator is an object of navigation functions that a view can call. It
-is passed as a prop to any component rendered by NavigatorIOS.
A navigation object contains the following functions:
push(route) - Navigate forward to a new routepop() - Go back one pagepopN(n) - Go back N pages at once. When N=1, behavior matches pop()replace(route) - Replace the route for the current page and immediately
-load the view for the new routereplacePrevious(route) - Replace the route/view for the previous pagereplacePreviousAndPop(route) - Replaces the previous route/view and
-transitions back to itresetTo(route) - Replaces the top item and popToToppopToRoute(route) - Go back to the item for a particular route objectpopToTop() - Go back to the top itemNavigator functions are also available on the NavigatorIOS component:
NavigatorIOS uses "route" objects to identify child views, their props, -and navigation bar configuration. "push" and all the other navigation -operations expect routes to be like this:
The default wrapper style for components in the navigator. -A common use case is to set the backgroundColor for every page
The color used for buttons in the navigation bar
NetInfo exposes info about online/offline status
Asyncronously determine if the device is online and on a cellular network.
none - device is offlinewifi - device is online and connected via wifi, or is the iOS simulatorcell - device is connected via Edge, 3G, WiMax, or LTEunknown - error case and the network status is unknownAvailable on all platforms. Asyncronously fetch a boolean to determine -internet connectivity.
One of React Native goal is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example.
XMLHttpRequest API is implemented on-top of iOS networking apis. The notable difference from web is the security model: you can read from arbitrary websites on the internet since there is no concept of CORS.
Please follow the MDN Documentation for a complete description of the API.
As a developer, you're probably not going to use XMLHttpRequest directly as its API is very tedious to work with. But the fact that it is implemented and compatible with the browser API gives you the ability to use third-party libraries such as Parse or super-agent directly from npm.
fetch is a better networking API being worked on by the standard committee and is already available in Chrome. It is available in React Native by default.
PanResponder reconciles several touches into a single gesture. It makes
-single-touch gestures resilient to extra touches, and can be used to
-recognize simple multi-touch gestures.
It provides a predictable wrapper of the responder handlers provided by the
-gesture responder system.
-For each handler, it provides a new gestureState object alongside the
-normal event.
A gestureState object has the following:
stateID - ID of the gestureState- persisted as long as there at least
- one touch on screenmoveX - the latest screen coordinates of the recently-moved touchmoveY - the latest screen coordinates of the recently-moved touchx0 - the screen coordinates of the responder granty0 - the screen coordinates of the responder grantdx - accumulated distance of the gesture since the touch starteddy - accumulated distance of the gesture since the touch startedvx - current velocity of the gesturevy - current velocity of the gesturenumberActiveTouches - Number of touches currently on screeenTo see it in action, try the -PanResponder example in UIExplorer
@param {object} config Enhanced versions of all of the responder callbacks
-that provide not only the typical ResponderSyntheticEvent, but also the
-PanResponder gesture state. Simply replace the word Responder with
-PanResponder in each of the typical onResponder* callbacks. For
-example, the config object would look like:
onMoveShouldSetPanResponder: (e, gestureState) => {...}onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}onStartShouldSetPanResponder: (e, gestureState) => {...}onStartShouldSetPanResponderCapture: (e, gestureState) => {...}onPanResponderReject: (e, gestureState) => {...}onPanResponderGrant: (e, gestureState) => {...}onPanResponderStart: (e, gestureState) => {...}onPanResponderEnd: (e, gestureState) => {...}onPanResponderRelease: (e, gestureState) => {...}onPanResponderMove: (e, gestureState) => {...}onPanResponderTerminate: (e, gestureState) => {...}onPanResponderTerminationRequest: (e, gestureState) => {...}
In general, for events that have capture equivalents, we update the -gestureState once in the capture phase and can use it in the bubble phase -as well.
Be careful with onStartShould* callbacks. They only reflect updated
-gestureState for start/end events that bubble/capture to the Node.
-Once the node is the responder, you can rely on every start/end event
-being processed by the gesture and gestureState being updated
-accordingly. (numberActiveTouches) may not be totally accurate unless you
-are the responder.
PixelRatio class gives access to the device pixel density.
There are a few use cases for using PixelRatio:
A width of 1 is actually pretty thick on an iPhone 4+, we can do one that's
-thinner using a width of 1 / PixelRatio.get(). It's a technique that works
-on all the devices independent of their pixel density.
You should get a higher resolution image if you are on a high pixel density -device. A good rule of thumb is to multiply the size of the image you display -by the pixel ratio.
Returns the device pixel density. Some examples:
In iOS, you can specify positions and dimensions for elements with arbitrary precision, for example 29.674825. But, ultimately the physical display only have a fixed number of pixels, for example 640×960 for iphone 4 or 750×1334 for iphone 6. iOS tries to be as faithful as possible to the user value by spreading one original pixel into multiple ones to trick the eye. The downside of this technique is that it makes the resulting element look blurry.
In practice, we found out that developers do not want this feature and they have to work around it by doing manual rounding in order to avoid having blurry elements. In React Native, we are rounding all the pixels automatically.
We have to be careful when to do this rounding. You never want to work with rounded and unrounded values at the same time as you're going to accumulate rounding errors. Having even one rounding error is deadly because a one pixel border may vanish or be twice as big.
In React Native, everything in JS and within the layout engine work with arbitrary precision numbers. It's only when we set the position and dimensions of the native element on the main thread that we round. Also, rounding is done relative to the root rather than the parent, again to avoid accumulating rounding errors.
Handle push notifications for your app, including permission handling and -icon badge number.
To get up and running, configure your notifications with Apple -and your server-side system. To get an idea, this is the Parse guide.
Sets the badge number for the app icon on the home screen
Gets the current badge number for the app icon on the home screen
Attaches a listener to remote notifications while the app is running in the -foreground or the background.
The handler will get be invoked with an instance of PushNotificationIOS
Requests all notification permissions from iOS, prompting the user's -dialog box.
See what push permissions are currently enabled. callback will be
-invoked with a permissions object:
alert :booleanbadge :booleansound :booleanRemoves the event listener. Do this in componentWillUnmount to prevent
-memory leaks
An initial notification will be available if the app was cold-launched -from a notification.
The first caller of popInitialNotification will get the initial
-notification object, or null. Subsequent invocations will return null.
You will never need to instansiate PushNotificationIOS yourself.
-Listening to the notification event and invoking
-popInitialNotification is sufficient
An alias for getAlert to get the notification's main message string
Gets the sound string from the aps object
Gets the notification's main message from the aps object
Gets the badge count number from the aps object
Gets the data object on the notif
Component that wraps platform ScrollView while providing -integration with touch locking "responder" system.
Doesn't yet support other contained responders from blocking this scroll -view from becoming the responder.
When true, the scroll view bounces horizontally when it reaches the end
-even if the content is smaller than the scroll view itself. The default
-value is true when horizontal={true} and false otherwise.
When true, the scroll view bounces vertically when it reaches the end
-even if the content is smaller than the scroll view itself. The default
-value is false when horizontal={true} and true otherwise.
When true, the scroll view automatically centers the content when the -content is smaller than the scroll view bounds; when the content is -larger than the scroll view, this property has no effect. The default -value is false.
These styles will be applied to the scroll view content container which -wraps all of the child views. Example:
return ( - <ScrollView contentContainerStyle={styles.contentContainer}> - </ScrollView> - ); - ... - var styles = StyleSheet.create({ - contentContainer: { - paddingVertical: 20 - } - });
A floating-point number that determines how quickly the scroll view -decelerates after the user lifts their finger. Reasonable choices include - - Normal: 0.998 (the default) - - Fast: 0.9
When true, the scroll view's children are arranged horizontally in a row -instead of vertically in a column. The default value is false.
Determines whether the keyboard gets dismissed in response to a drag. - - 'none' (the default), drags do not dismiss the keyboard. - - 'onDrag', the keyboard is dismissed when a drag begins. - - 'interactive', the keyboard is dismissed interactively with the drag - and moves in synchrony with the touch; dragging upwards cancels the - dismissal.
When false, tapping outside of the focused text input when the keyboard -is up dismisses the keyboard. When true, the scroll view will not catch -taps, and the keyboard will not dismiss automatically. The default value -is false.
The maximum allowed zoom scale. The default value is 1.0.
The minimum allowed zoom scale. The default value is 1.0.
When true, the scroll view stops on multiples of the scroll view's size -when scrolling. This can be used for horizontal pagination. The default -value is false.
Experimental: When true, offscreen child views (whose overflow value is
-hidden) are removed from their native backing superview when offscreen.
-This canimprove scrolling performance on long lists. The default value is
-false.
When true, the scroll view scrolls to top when the status bar is tapped. -The default value is true.
An array of child indices determining which children get docked to the
-top of the screen when scrolling. For example, passing
-stickyHeaderIndices={[0]} will cause the first child to be fixed to the
-top of the scroll view. This property is not supported in conjunction
-with horizontal={true}.
The current scale of the scroll view content. The default value is 1.0.
Initial maximum value of the slider. Default value is 1.
Initial minimum value of the slider. Default value is 0.
Callback called when the user finishes changing the value (e.g. when -the slider is released).
Callback continuously called while the user is dragging the slider.
Used to style and layout the Slider. See StyleSheet.js and
-ViewStylePropTypes.js for more info.
Initial value of the slider. The value should be between minimumValue -and maximumValue, which default to 0 and 1 respectively. -Default value is 0.
This is not a controlled component, e.g. if you don't update -the value, the component won't be reset to it's inital value.
All rights reserved.
This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.
@flow
React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.
- -The way to declare styles in React Native is the following:
StyleSheet.create construct is optional but provides some key advantages. It ensures that the values are immutable and opaque by transforming them into plain numbers that reference an internal table. By putting it at the end of the file, you also ensure that they are only created once for the application and not on every render.
All the attribute names and values are a subset of what works on the web. For layout, React Native implements Flexbox.
All the core components accept a style attribute
and also accepts an array of styles
The behavior is the same as Object.assign: in case of conflicting values, the one from the right-most element will have precedence and falsy values like false, undefined and null will be ignored. A common pattern is to conditionally add a style based on some condition.
Finally, if you really have to, you can also create style objects in render, but they are highly discouraged. Put them last in the array definition.
In order to let a call site customize the style of your component children, you can pass styles around. Use View.propTypes.style and Text.propTypes.style in order to make sure only styles are being passed.
A StyleSheet is an abstraction similar to CSS StyleSheets
Create a new StyleSheet:
Use a StyleSheet:
Code quality:
Performance:
Use SwitchIOS to render a boolean input on iOS. This is
-a controlled component, so you must hook in to the onValueChange callback
-and update the value prop in order for the component to update, otherwise
-the user's change will be reverted immediately to reflect props.value as the
-source of truth.
If true the user won't be able to toggle the switch. -Default value is false.
Background color when the switch is turned on.
Callback that is called when the user toggles the switch.
Background color for the switch round button.
Background color when the switch is turned off.
The value of the switch, if true the switch will be turned on. -Default value is false.
The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR. You can also run them locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode. You can run the jest tests via npm test on the command line. We don't have great test coverage yet, however, so most changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage!
Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with npm test from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.
React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS via NativeModules as TestModule. The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing an exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria. See IntegrationTestHarnessTest.js and IntegrationTestsTests.m for example usage.
A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.
A react component for displaying text which supports nesting,
-styling, and touch handling. In the following example, the nested title and
-body text will inherit the fontFamily from styles.baseText, but the title
-provides its own additional styles. The title and body will stack on top of
-each other on account of the literal newlines:
Used to truncate the text with an elipsis after computing the text -layout, including line wrapping, such that the total number of lines does -not exceed this number.
This function is called on press. Text intrinsically supports press
-handling with a default highlight state (which can be disabled with
-suppressHighlighting).
When true, no visual change is made when text is pressed down. By -default, a gray oval highlights the text on press down.
Used to locate this view in end-to-end tests.
In iOS, the way to display formatted text is by using NSAttributedString: you give the text that you want to display and annotate ranges with some specific formatting. In practice, this is very tedious. For React Native, we decided to use web paradigm for this where you can nest text to achieve the same effect.
Behind the scenes, this is going to be converted to a flat NSAttributedString that contains the following information
The <Text> element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a <Text> are no longer rectangles, but wrap when they see the end of the line.
On the web, the usual way to set a font family and size for the entire document is to write:
When the browser is trying to render a text node, it's going to go all the way up to the root element of the tree and find an element with a font-size attribute. An unexpected property of this system is that any node can have font-size attribute, including a <div>. This was designed for convenience, even though not really semantically correct.
In React Native, we are more strict about it: you must wrap all the text nodes inside of a <Text> component; you cannot have a text node directly under a <View>.
You also lose the ability to set up a default font for an entire subtree. The recommended way to use consistent fonts and sizes across your application is to create a component MyAppText that includes them and use this component across your app. You can also use this component to make more specific components like MyAppHeaderText for other kinds of text.
React Native still has the concept of style inheritance, but limited to text subtrees. In this case, the second part will be both bold and red.
We believe that this more constrained way to style text will yield better apps:
(Developer) React components are designed with strong isolation in mind: You should be able to drop a component anywhere in your application, trusting that as long as the props are the same, it will look and behave the same way. Text properties that could inherit from outside of the props would break this isolation.
(Implementor) The implementation of React Native is also simplified. We do not need to have a fontFamily field on every single element, and we do not need to potentially traverse the tree up to the root every time we display a text node. The style inheritance is only encoded inside of the native Text component and doesn't leak to other components or the system itself.
A foundational component for inputting text into the app via a -keyboard. Props provide configurability for several features, such as auto- -correction, auto-capitalization, placeholder text, and different keyboard -types, such as a numeric keypad.
The simplest use case is to plop down a TextInput and subscribe to the
-onChangeText events to read the user input. There are also other events, such
-as onSubmitEditing and onFocus that can be subscribed to. A simple
-example:
The value prop can be used to set the value of the input in order to make
-the state of the component clear, but <TextInput> does not behave as a true
-controlled component by default because all operations are asynchronous.
-Setting value once is like setting the default value, but you can change it
-continuously based on onChangeText events as well. If you really want to
-force the component to always revert to the value you are setting, you can
-set controlled={true}.
The multiline prop is not supported in all releases, and some props are
-multiline only.
Can tell TextInput to automatically capitalize certain characters.
If false, disables auto-correct. Default value is true.
If true, focuses the input on componentDidMount. Default value is false.
This helps avoid drops characters due to race conditions between JS and -the native text input. The default should be fine, but if you're -potentially doing very slow operations on every keystroke then you may -want to try increasing this.
When the clear button should appear on the right side of the text view
If you really want this to behave as a controlled component, you can set -this true, but you will probably see flickering, dropped keystrokes, -and/or laggy typing, depending on how you process onChange events.
If false, text is not editable. Default value is true.
Determines which keyboard to open, e.g.numeric.
If true, the text input can be multiple lines. Default value is false.
Callback that is called when the text input is blurred
(text: string) => void
Callback that is called when the text input's text changes.
Callback that is called when the text input is focused
The string that will be rendered before text input has been entered
The text color of the placeholder string
See DocumentSelectionState.js, some state that is responsible for -maintaining selection information for a document
The default value for the text input
Timers are an important part of an application and React Native implements the browser timers.
requestAnimationFrame(fn) is the exact equivalent of setTimeout(fn, 0), they are triggered right after the screen has been flushed.
setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.
The Promise implementation uses setImmediate as its asynchronicity primitive.
One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.
Applications can schedule tasks to run after interactions with the following:
Compare this to other scheduling alternatives:
The touch handling system considers one or more active touches to be an 'interaction' and will delay runAfterInteractions() callbacks until all touches have ended or been cancelled.
InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:
We found out that the primary cause of fatals in apps created with React Native was due to timers firing after a component was unmounted. To solve this recurring issue, we introduced TimerMixin. If you include TimerMixin, then you can replace your calls to setTimeout(fn, 500) with this.setTimeout(fn, 500) (just prepend this.) and everything will be properly cleaned up for you when the component unmounts.
We highly recommend never using bare timers and always using this mixin, it will save you from a lot of hard to track down bugs.
A wrapper for making views respond properly to touches. -On press down, the opacity of the wrapped view is decreased, which allows -the underlay color to show through, darkening or tinting the view. The -underlay comes from adding a view to the view hierarchy, which can sometimes -cause unwanted visual artifacts if not used correctly, for example if the -backgroundColor of the wrapped view isn't explicitly set to an opaque color.
Example:
Determines what the opacity of the wrapped view should be when touch is -active.
The color of the underlay that will show through when the touch is -active.
A wrapper for making views respond properly to touches. -On press down, the opacity of the wrapped view is decreased, dimming it. -This is done without actually changing the view hierarchy, and in general is -easy to add to an app without weird side-effects.
Example:
Determines what the opacity of the wrapped view should be when touch is -active.
Do not use unless you have a very good reason. All the elements that -respond to press should have a visual feedback when touched. This is -one of the primary reason a "web" app doesn't feel "native".
This tutorial aims to get you up to speed with writing iOS apps using React Native. If you're wondering what React Native is and why Facebook built it, this blog post explains that.
We assume you have experience writing websites with React. If not, you can learn about it on the React website.
React Native requires OSX, Xcode, Homebrew, node, npm, and watchman. Flow is optional.
After installing these dependencies there are two simple commands to get a React Native project all set up for development.
npm install -g react-native-cli
react-native-cli is a command line interface that does the rest of the set up. It’s installable via npm. This will install react-nativeas a command in your terminal. You only ever need to do this once.
react-native init AwesomeProject
This command fetches the React Native source code and dependencies and then creates a new Xcode project in AwesomeProject/AwesomeProject.xcodeproj.
You can now open this new project (AwesomeProject/AwesomeProject.xcodeproj) in Xcode and simply build and run it with cmd+R. Doing so will also start a node server which enables live code reloading. With this you can see your changes by pressing cmd+R in the simulator rather than recompiling in Xcode.
For this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.
react-native init will copy Examples/SampleProject to whatever you named your project, in this case AwesomeProject. This is a simple hello world app. You can edit index.ios.js to make changes to the app and then press cmd+R in the simulator to see the changes.
Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the requires, but feel free to add the following constant wherever you like. In index.ios.js:
We're going to render the title, year, and thumbnail for the movie. Since thumbnail is an Image component in React Native, add Image to the list of React requires below.
Now change the render function so that we're rendering the data mentioned above rather than hello world.
Press cmd+R and you should see "Title" above "2015". Notice that the Image doesn't render anything. This is because we haven't specified the width and height of the image we want to render. This is done via styles. While we're changing the styles let's also clean up the styles we're no longer using.
And lastly we need to apply this style to the Image component:
Press cmd+R and the image should now render.
-Great, we've rendered our data. Now let's make it look better. I'd like to put the text to the right of the image and make the title larger and centered within that area:
We'll need to add another container in order to vertically lay out components within horizontally layed out components.
Not too much has changed, we added a container around the Texts and then moved them after the Image (because they're to the right of the Image). Let's see what the style changes look like:
We use FlexBox for layout - see this great guide to learn more about it.
In the above code snippet, we simply added flexDirection: 'row' that will make children of our main container to be layed out horizontally instead of vertically.
Now add another style to the JS style object:
This means that the rightContainer takes up the remaining space in the parent container that isn't taken up by the Image. If this doesn't make sense, add a backgroundColor to rightContainer and then try removing the flex: 1. You'll see that this causes the container's size to be the minimum size that fits its children.
Styling the text is pretty straightforward:
Go ahead and press cmd+R and you'll see the updated view.
-Fetching data from Rotten Tomatoes's API isn't really relevant to learning React Native so feel free to breeze through this section.
Add the following constants to the top of the file (typically below the requires) to create the REQUEST_URL used to request data with.
Add some initial state to our application so that we can check this.state.movies === null to determine whether the movies data has been loaded or not. We can set this data when the response comes back with this.setState({movies: moviesData}). Add this code just above the render function inside our React class.
We want to send off the request after the component has finished loading. componentDidMount is a function of React components that React will call exactly once, just after the component has been loaded.
Now add fetchData function used above to our main component. This method will be responsible for handling data fetching. All you need to do is call this.setState({movies: data}) after resolving the promise chain because the way React works is that setState actually triggers a re-render and then the render function will notice that this.state.movies is no longer null. Note that we call done() at the end of the promise chain - always make sure to call done() or any errors thrown will get swallowed.
Now modify the render function to render a loading view if we don't have any movies data, and to render the first movie otherwise.
Now press cmd+R and you should see "Loading movies..." until the response comes back, then it will render the first movie it fetched from Rotten Tomatoes.
-Let's now modify this application to render all of this data in a ListView component, rather than just rendering the first movie.
Why is a ListView better than just rendering all of these elements or putting them in a ScrollView? Despite React being fast, rendering a possibly infinite list of elements could be slow. ListView schedules rendering of views so that you only display the ones on screen and those already rendered but off screen are removed from the native view hierarchy.
First thing's first: add the ListView require to the top of the file.
Now modify the render function so that once we have our data it renders a ListView of movies instead of a single movie.
The DataSource is an interface that ListView is using to determine which rows have changed over the course of updates.
You'll notice we used dataSource from this.state. The next step is to add an empty dataSource to the object returned by getInitialState. Also, now that we're storing the data in dataSource, we should no longer use this.state.movies to avoid storing data twice. We can use boolean property of the state (this.state.loaded) to tell whether data fetching has finished.
And here is the modified fetchData method that updates the state accordingly:
Finally, we add styles for the ListView component to the styles JS object:
And here's the final result:
-There's still some work to be done to make it a fully functional app such as: adding navigation, search, infinite scroll loading, etc. Check the Movies Example to see it all working.
The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this
-function will trigger a one second vibration. The vibration is asynchronous
-so this method will return immediately.
There will be no effect on devices that do not support Vibration, eg. the iOS -simulator.
Vibration patterns are currently unsupported.
With Christopher "vjeux" Chedeau and Spencer Ahrens
- -With Christopher "vjeux" Chedeau and Jordan Walke
-The most fundamental component for building UI, View is a
-container that supports layout with flexbox, style, some touch handling, and
-accessibility controls, and is designed to be nested inside other views and
-to have 0 to many children of any type. View maps directly to the native
-view equivalent on whatever platform react is running on, whether that is a
-UIView, <div>, android.view, etc. This example creates a View that
-wraps two colored boxes and custom component in a row with padding.
Views are designed to be used with StyleSheets for clarity and
-performance, although inline styles are also supported.
Overrides the text that's read by the screen reader when the user interacts -with the element. By default, the label is constructed by traversing all the -children and accumulating all the Text nodes separated by space.
When true, indicates that the view is an accessibility element. By default, -all the touchable elements are accessible.
For most touch interactions, you'll simply want to wrap your component in
-TouchableHighlight or TouchableOpacity. Check out Touchable.js,
-ScrollResponder.js and ResponderEventPlugin.js for more discussion.
In the absence of auto property, none is much like CSS's none
-value. box-none is as if you had applied the CSS class:
box-only is the equivalent of
But since pointerEvents does not affect layout/appearance, and we are
-already deviating from the spec by adding additional modes, we opt to not
-include pointerEvents on style. On some platforms, we would need to
-implement it as a className anyways. Using style or not is an
-implementation detail of the platform.
This is a special performance property exposed by RCTView and is useful -for scrolling content when there are many subviews, most of which are -offscreen. For this property to be effective, it must be applied to a -view that contains many subviews that extend outside its bound. The -subviews must also have overflow: hidden, as should the containing view -(or one of its superviews).
Used to locate this view in end-to-end tests.