diff --git a/_index.html b/_index.html index 58eaa647bb2..ecc56094d60 100644 --- a/_index.html +++ b/_index.html @@ -1,4 +1,52 @@ -
With React Native, you can use the platform components such as iOS UITabBar and UINavigationController.
Decoding images off of the main thread... Asynchronous bridge, Chrome Dev Tools...
iOS has a very powerful system called Responder to handle touches which the web lacks. React Native implements iOS responder system and provides high level components such as TouchableHighlight that work well right off the bat.
Laying out views should be easy
React Native attempts to innovate on the view layer, for the rest, it polyfills web standards. You can use npm to install JavaScript dependencies, XMLHttpRequest, requestAnimationFrame, navigator.geolocation...
AlertIOS manages native iOS alerts, option sheets, and share dialogs
All rights reserved.
This source code is licensed under the BSD-style license found in the +
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
+
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.
All rights reserved.
This source code is licensed under the BSD-style license found in the +
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.
AsyncStorage is a simple, asynchronous, persistent, global, key-value storage +
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 diff --git a/docs/cameraroll.html b/docs/cameraroll.html index b4019ae9518..128cd088f33 100644 --- a/docs/cameraroll.html +++ b/docs/cameraroll.html @@ -1,4 +1,4 @@ -
All rights reserved.
This source code is licensed under the BSD-style license found in the +
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.
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 diff --git a/docs/datepickerios.html b/docs/datepickerios.html index 0fe476686d1..4a16c4d7b6e 100644 --- a/docs/datepickerios.html +++ b/docs/datepickerios.html @@ -1,4 +1,4 @@ -
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
diff --git a/docs/flexbox.html b/docs/flexbox.html
index f90bac02494..ad6e33acf06 100644
--- a/docs/flexbox.html
+++ b/docs/flexbox.html
@@ -1,4 +1,4 @@
-
Our first React Native implementation is ReactKit, targeting iOS. We are also
+
Our first React Native implementation is ReactKit, targeting iOS. We are also
working on an Android implementation which we will release later. ReactKit
apps are built using the React JS framework, and render directly to
native UIKit elements using a fully asynchronous architecture. There is no
diff --git a/docs/image.html b/docs/image.html
index 7207629d8e6..47ef17a89d1 100644
--- a/docs/image.html
+++ b/docs/image.html
@@ -1,4 +1,4 @@
-
A 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:
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:
All rights reserved.
This source code is licensed under the BSD-style license found in the +
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.
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
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 ce6718634e4..fa64701277a 100644
--- a/docs/mapview.html
+++ b/docs/mapview.html
@@ -1,4 +1,4 @@
-
Insets for the map's legal label, originally at bottom left of the map. +
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
diff --git a/docs/nativemodulesios.html b/docs/nativemodulesios.html
index 6a035cab8a0..2c7b177209a 100644
--- a/docs/nativemodulesios.html
+++ b/docs/nativemodulesios.html
@@ -1,4 +1,4 @@
-
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.
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.
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 initialRoute:
NetInfo exposes info about online/offline status
== iOS Reachability
Asyncronously determine if the device is online and on a cellular network.
NetInfo exposes info about online/offline status
== iOS Reachability
Asyncronously determine if the device is online and on a cellular network.
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.
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.
+----------------------------+ +--------------------------------+ +| ResponderTouchHistoryStore | |TouchHistoryMath | ++----------------------------+ +----------+---------------------+ +|Global store of touchHistory| |Allocation-less math util | +|including activeness, start | |on touch history (centroids | +|position, prev/cur position.| |and multitouch movement etc) | +| | | | ++----^-----------------------+ +----^---------------------------+ + | | + | (records relevant history | + | of touches relevant for | + | implementing higher level | + | gestures) | + | | ++----+-----------------------+ +----|---------------------------+ +| ResponderEventPlugin | | | Your App/Component | ++----------------------------+ +----|---------------------------+ +|Negotiates which view gets | Low level | | High level | +|onResponderMove events. | events w/ | +-+-------+ events w/ | +|Also records history into | touchHistory| | Pan | multitouch + | +|ResponderTouchHistoryStore. +---------------->Responder+-----> accumulative| ++----------------------------+ attached to | | | distance and | + each event | +---------+ velocity. | + | | + | | + +--------------------------------+
Gesture that calculates cumulative movement over time in a way that just +"does the right thing" for multiple touches. The "right thing" is very +nuanced. When moving two touches in opposite directions, the cumulative +distance is zero in each dimension. When two touches move in parallel five +pixels in the same direction, the cumulative distance is five, not ten. If +two touches start, one moves five in a direction, then stops and the other +touch moves fives in the same direction, the cumulative distance is ten.
This logic requires a kind of processing of time "clusters" of touch events +so that two touch moves that essentially occur in parallel but move every +other frame respectively, are considered part of the same movement.
Explanation of some of the non-obvious fields:
(moveX, moveY) is
+invalid. If a move event has been observed, (moveX, moveY) is the
+centroid of the most recently moved "cluster" of active touches.
+(Currently all move have the same timeStamp, but later we should add some
+threshold for what is considered to be "moving"). If a palm is
+accidentally counted as a touch, but a finger is moving greatly, the palm
+will move slightly, but we only want to count the single moving touch.This is nuanced and is necessary. It is incorrect to continuously take all +active and recently moved touches, find the centroid, and track how that +result changes over time. Instead, we must take all recently moved +touches, and calculate how the centroid has changed just for those +recently moved touches, and append that change to an accumulator. This is +to (at least) handle the case where the user is moving three fingers, and +then one of the fingers stops but the other two continue.
This is very different than taking all of the recently moved touches and
+storing their centroid as dx/dy. For correctness, we must accumulate
+changes in the centroid of recently moved touches.
There is also some nuance with how we handle multiple moved touches in a
+single event. With the way ReactIOSEventEmitter dispatches touches as
+individual events, multiple touches generate two 'move' events, each of
+them triggering onResponderMove. But with the way PanResponder works,
+all of the gesture inference is performed on the first dispatch, since it
+looks at all of the touches (even the ones for which there hasn't been a
+native dispatch yet). Therefore, PanResponder does not call
+onResponderMove passed the first dispatch. This diverges from the
+typical responder callback pattern (without using PanResponder), but
+avoids more dispatches than necessary.
@param {object} config Enhanced versions of all of the responder callbacks
+that accept 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:
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 +
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 @@ -6,7 +6,7 @@ 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.
A width of 1 is actually 2 physical pixels thick on an iPhone 4 and 3 physical pixels thick on an iphone 6+. If you want to display a line that's as thin as possible, you can use 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.
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.
A width of 1 is actually 2 physical pixels thick on an iPhone 4 and 3 physical pixels thick on an iphone 6+. If you want to display a line that's as thin as possible, you can use 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.
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
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
Component that wraps platform ScrollView while providing +
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 @@ -39,7 +39,7 @@ The default value is true.
The current scale of the scroll view content. The default value is 1.0.
Callback called when the user finishes changing the value (e.g. when +
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 0 and 1. Default value is 0.
This is not a controlled component, e.g. if you don't update diff --git a/docs/statusbarios.html b/docs/statusbarios.html index c6ba2e9519e..5191ac590a1 100644 --- a/docs/statusbarios.html +++ b/docs/statusbarios.html @@ -1,4 +1,4 @@ -
All rights reserved.
This source code is licensed under the BSD-style license found in the +
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
The way to declare styles in React Native is the following:
The way to declare styles in React Native is the following:
A StyleSheet is an abstraction similar to CSS StyleSheets
Create a new StyleSheet:
A StyleSheet is an abstraction similar to CSS StyleSheets
Create a new StyleSheet:
Performance:
Use SwitchIOS to render a boolean input on iOS. This is
+
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
diff --git a/docs/tabbarios.html b/docs/tabbarios.html
index 33bffb237e8..b467f0a6d75 100644
--- a/docs/tabbarios.html
+++ b/docs/tabbarios.html
@@ -1,4 +1,4 @@
-
A react component for displaying text which supports nesting, +
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
diff --git a/docs/textinput.html b/docs/textinput.html
index 8b68d1effc2..3be1c26eee0 100644
--- a/docs/textinput.html
+++ b/docs/textinput.html
@@ -1,4 +1,4 @@
-
A foundational component for inputting text into the app via a +
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
diff --git a/docs/timers.html b/docs/timers.html
index 58717d8d648..1693c8b9af3 100644
--- a/docs/timers.html
+++ b/docs/timers.html
@@ -1,4 +1,4 @@
-
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:
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: