diff --git a/docs/activityindicatorios.html b/docs/activityindicatorios.html index b0d6abd64a5..39acc401e13 100644 --- a/docs/activityindicatorios.html +++ b/docs/activityindicatorios.html @@ -1,4 +1,4 @@ -
Launches an alert dialog with the specified title and message.
Optionally provide a list of buttons. Tapping any button will fire the +
Launches an alert dialog with the specified title and message.
Optionally provide a list of buttons. Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button
The last button in the list will be considered the 'Primary' button and it will appear bold.
AppRegistry is the JS entry point to running all React Native apps. App
+
AppRegistry is the JS entry point to running all React Native apps. App
root components should register themselves with
AppRegistry.registerComponent, then the native system can load the bundle
for the app and then actually run the app when it's ready by invoking
diff --git a/docs/appstateios.html b/docs/appstateios.html
index be037712af1..ea595bb61ca 100644
--- a/docs/appstateios.html
+++ b/docs/appstateios.html
@@ -1,4 +1,4 @@
-
AppStateIOS can tell you if the app is in the foreground or background,
+
AppStateIOS can tell you if the app is in the foreground or background,
and notify you when the state changes.
AppStateIOS is frequently used to determine the intent and proper behavior when handling push notifications.
active - The app is running in the foregroundbackground - The app is running in the background. The user is either
in another app or on the home screeninactive - This is a transition state that currently never happens for
diff --git a/docs/asyncstorage.html b/docs/asyncstorage.html
index 262603bd5e1..11280a89f54 100644
--- a/docs/asyncstorage.html
+++ b/docs/asyncstorage.html
@@ -1,4 +1,4 @@
-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 e1a0e94e421..7e5170bcf79 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.
@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 diff --git a/docs/datepickerios.html b/docs/datepickerios.html index ac37d4b58ce..c532ec71f36 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/debugging.html b/docs/debugging.html
index 482a564fa95..f39e5ecca3d 100644
--- a/docs/debugging.html
+++ b/docs/debugging.html
@@ -1,4 +1,4 @@
-
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.Hint
To debug on a real device: Open the file
RCTWebSocketExecutor.mand changelocalhostto the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
Install the React Developer Tools extension for Google Chrome. This will allow you to navigate the 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.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.Hint
To debug on a real device: Open the file
RCTWebSocketExecutor.mand changelocalhostto the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
Install the React Developer Tools extension for Google Chrome. This will allow you to navigate the 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.Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.
CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't install CocoaPods yet, checkout this tutorial.
When you are ready to work with CocoaPods, add the following line to Podfile. If you don't have one, then create it under the root directory of your project.
Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the V in MVC – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like CocoaPods.
CocoaPods is a package management tool for iOS/Mac development. We need to use it to download React Native. If you haven't install CocoaPods yet, checkout this tutorial.
When you are ready to work with CocoaPods, add the following line to Podfile. If you don't have one, then create it under the root directory of your project.
Remember to install all subspecs you need. The <Text> element cannot be used without pod 'React/RCTText'.
Then install your pods:
There are two pieces you’ll need to set up:
RCTRootView to display and manage your React Native componentsFirst, create a directory for your app’s React code and create a simple index.ios.js file:
Copy & paste following starter code for index.ios.js – it’s a barebones React Native app:
You need to include the NSLocationWhenInUseUsageDescription key
+
You need to include the NSLocationWhenInUseUsageDescription key
in Info.plist to enable geolocation. Geolocation is enabled by default
when you create a project with react-native init.
Geolocation follows the MDN specification: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.
The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:
These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.
The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.
A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:
View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?If the View returns true and attempts to become the responder, one of the following will happen:
View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happeningView.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release itIf the view is responding, the following handlers can be called:
View.props.onResponderMove: (evt) => {} - The user is moving their fingerView.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows releaseView.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)evt is a synthetic touch event with the following form:
nativeEventchangedTouches - Array of all touch events that have changed since the last eventidentifier - The ID of the touchlocationX - The X position of the touch, relative to the elementlocationY - The Y position of the touch, relative to the elementpageX - The X position of the touch, relative to the screenpageY - The Y position of the touch, relative to the screentarget - The node id of the element receiving the touch eventtimestamp - A time identifier for the touch, useful for velocity calculationtouches - Array of all current touches on the screenonStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.
However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.
View.props.onStartShouldSetResponderCapture: (evt) => true,View.props.onMoveShouldSetResponderCapture: (evt) => true,For higher-level gesture interpretation, check out PanResponder.
Gesture recognition on mobile devices is much more complicated than web. A touch can go through several phases as the app determines what the user's intention is. For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.
The touch responder system is needed to allow components to negotiate these touch interactions without any additional knowledge about their parent or child components. This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. Every action should have the following attributes:
These features make users more comfortable while using an app, because it allows people to experiment and interact without fear of making mistakes.
The responder system can be complicated to use. So we have provided an abstract Touchable implementation for things that should be "tappable". This uses the responder system and allows you to easily configure tap interactions declaratively. Use TouchableHighlight anywhere where you would use a button or link on web.
A view can become the touch responder by implementing the correct negotiation methods. There are two methods to ask the view if it wants to become responder:
View.props.onStartShouldSetResponder: (evt) => true, - Does this view want to become responder on the start of a touch?View.props.onMoveShouldSetResponder: (evt) => true, - Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?If the View returns true and attempts to become the responder, one of the following will happen:
View.props.onResponderGrant: (evt) => {} - The View is now responding for touch events. This is the time to highlight and show the user what is happeningView.props.onResponderReject: (evt) => {} - Something else is the responder right now and will not release itIf the view is responding, the following handlers can be called:
View.props.onResponderMove: (evt) => {} - The user is moving their fingerView.props.onResponderRelease: (evt) => {} - Fired at the end of the touch, ie "touchUp"View.props.onResponderTerminationRequest: (evt) => true - Something else wants to become responder. Should this view release the responder? Returning true allows releaseView.props.onResponderTerminate: (evt) => {} - The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS)evt is a synthetic touch event with the following form:
nativeEventchangedTouches - Array of all touch events that have changed since the last eventidentifier - The ID of the touchlocationX - The X position of the touch, relative to the elementlocationY - The Y position of the touch, relative to the elementpageX - The X position of the touch, relative to the screenpageY - The Y position of the touch, relative to the screentarget - The node id of the element receiving the touch eventtimestamp - A time identifier for the touch, useful for velocity calculationtouches - Array of all current touches on the screenonStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable.
However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true.
View.props.onStartShouldSetResponderCapture: (evt) => true,View.props.onMoveShouldSetResponderCapture: (evt) => true,For higher-level gesture interpretation, check out PanResponder.
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.
If you run into any issues getting started, see the troubleshooting page.
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.
If you run into any issues getting started, see the troubleshooting page.
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:
When using React Native, you're going to be running your JavaScript code in two environments:
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.
React Native ships with many JavaScript transforms to make writing code more enjoyable. If you are curious, you can see the implementation of all those transformations. Here's the full list:
ES5
promise.catch(function() { });ES6
<C onPress={() => this.setState({pressed: true})}Math.max(...array);class C extends React.Component { render() { return <View />; } }var {isActive, style} = this.props;for (var element of array) { }var key = 'abc'; var obj = {[key]: 10};var obj = { method() { return 10; } };var name = 'vjeux'; var obj = { name };function(type, ...args) { }var who = 'world'; var str = `Hello ${who}`;ES7
var extended = { ...obj, a: 10 };function f(a, b, c,) { }When using React Native, you're going to be running your JavaScript code in two environments:
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.
React Native ships with many JavaScript transforms to make writing code more enjoyable. If you are curious, you can see the implementation of all those transformations. Here's the full list:
ES5
promise.catch(function() { });ES6
<C onPress={() => this.setState({pressed: true})}Math.max(...array);class C extends React.Component { render() { return <View />; } }var {isActive, style} = this.props;for (var element of array) { }var key = 'abc'; var obj = {[key]: 10};var obj = { method() { return 10; } };var name = 'vjeux'; var obj = { name };function(type, ...args) { }var who = 'world'; var str = `Hello ${who}`;ES7
var extended = { ...obj, a: 10 };function f(a, b, c,) { }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
Not every app uses all the native capabilities, and including the code to support +
Not every app uses all the native capabilities, and including the code to support all those features would impact the binary size... But we still want to make it easy to add these features whenever you need them.
With that in mind we exposed many of these features as independent static libraries.
For most of the libs it will be as simple as dragging two files, sometimes a third step will be necessary, but no more than that.
All the libraries we ship with React Native live on the If your app was launched from a external url registered to your app you can
access and handle it from any component you want with ListView - A core component designed for efficient display of vertically
+ ListView - A core component designed for efficient display of vertically
scrolling lists of changing data. The minimal API is to create a
Map annotations with title/subtitle. Insets for the map's legal label, originally at bottom left of the map.
+ Map annotations with title/subtitle. Insets for the map's legal label, originally at bottom left of the map.
See 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 There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still more might be in use in your very own portfolio. React Native has several of the most critical platform components already wrapped, like Like the native module guide, this too is a more advanced guide that assumes you are somewhat familiar with iOS programming. This guide will show you how to build a native UI component, walking you through the implementation of a subset of the existing Let's say we want to add an interactive Map to our app - might as well use Native views are created and manipulated by subclasses of Vending a view is simple:
+- Create the basic subclass.
+- Add the Then you just need a little bit of JavaScript to make this a usable React component: This is now a fully-functioning native map view component in JavaScript, complete with pinch-zoom and other native gesture support. We can't really control it from JavaScript yet, though :( The first thing we can do to make this component more usable is to bridge over some native properties. Let's say we want to be able to disable pitch control specify the visible region. Disabling pitch is a simple boolean, so we just add this one line: Note that we explicitly specify the type as Now to actually disable pitch, we just set the property in JS: This isn't very well documented though - in order to know what properties are available and what values they accept, the client of your new component needs to dig through the Objective-C code. To make this better, let's make a wrapper component and document the interface with React Now we have a nicely documented wrapper component that is easy to work with. Note that we changed the second argument to Next, let's add the more complex Ok, this is clearly more complicated than the simple You could of course write any conversion function you want for your view - here is the implementation for These conversion functions are designed to safely process any JSON that the JS might throw at them by displaying "RedBox" errors and returning standard initialization values when missing keys or other developer errors are encountered. To finish up support for the Here you can see that the shape of the region is explicit in the JS documentation - ideally we could codegen some of this stuff, but that's not happening yet. So now we have a native map component that we can control easily from JS, but how do we deal with events from the user, like pinch-zooms or panning to change the visible region? The key is to make the You can see we're setting the manager as the delegate for every view that it vends, then in the delegate method Since all our native react views are subclasses of The This guide covered many of the aspects of bridging over custom native components, but there is even more you might need to consider, such as custom hooks for inserting and laying out subviews. If you want to go even deeper, check out the actual Sometimes an app needs access to 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 the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript. A native module is just an Objective-C class that implements the Sometimes an app needs access to platform API, and React Native doesn't have a corresponding module yet. Maybe you want to reuse some existing Objective-C or C++ code without having to reimplement it in JavaScript, or write some high performance, multi-threaded code such as for image processing, a database, or any number of advanced extensions. We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself. This is a more advanced guide that shows how to build a native module. It assumes the reader knows Objective-C (Swift is not supported yet) and core libraries (Foundation, UIKit). This guide will use the iOS Calendar API example. Let's say we would like to be able to access the iOS calendar from JavaScript. A native module is just an Objective-C class that implements the In addition to implementing the In addition to implementing the Now, from your JavaScript file you can call the method like this: NOTE: JavaScript method names The name of the method exported to JavaScript is the native method's name up to the first colon. React Native also defines a macro called The return type of bridge methods is always But it also works with any type that is supported by the In our NOTE: JavaScript method names The name of the method exported to JavaScript is the native method's name up to the first colon. React Native also defines a macro called The return type of bridge methods is always But it also works with any type that is supported by the In our or like this: But by using the automatic type conversion feature, we can skip the manual conversion step completely, and just write: You would then call this from JavaScript by using: or As You would then call this from JavaScript by using either: or And both values would get converted correctly to the native As NOTE: About array and map Objective-C doesn't provide any guarantees about the types of values in these structures. Your native module might expect an array of strings, but if JavaScript calls your method with an array containing numbers and strings, you'll get an WARNING This section is 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- a callback. In most cases it is used to provide the function call result to JavaScript. NOTE: About array and map Objective-C doesn't provide any guarantees about the types of values in these structures. Your native module might expect an array of strings, but if JavaScript calls your method with an array containing numbers and strings, you'll get an WARNING This section is more experimental than others because we don't have a solid set of best practices around callbacks yet. Native modules also supports a special kind of argument- a callback. In most cases it is used to provide the function call result to JavaScript. Native module is supposed to invoke its 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 If you want to pass error-like object to JavaScript, use 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: A native module is supposed to invoke its callback only once. It can, however, store the callback and invoke it later. This pattern is often used to wrap iOS APIs that require delegates. See If you want to pass error-like objects to JavaScript, use 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. The 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 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. Similarly, if an operation may take a long time to complete, the native module should not block and can specify it's own queue to run operations on. For example, the A native module can export constants that are immediately available to JavaScript at runtime. This is useful for communicating static data that would otherwise require a round-trip through the bridge. JavaScript can use this value right away: Note that the constants are exported only at initialization time, so if you change The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use JavaScript can use this value right away, synchronously: Note that the constants are exported only at initialization time, so if you change The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use For more examples of sending events to JavaScript, see Use Use To change the animation or gesture properties of the scene, provide a
diff --git a/docs/navigatorios.html b/docs/navigatorios.html
index 9e7b929c8a8..d4cddfa3107 100644
--- a/docs/navigatorios.html
+++ b/docs/navigatorios.html
@@ -1,4 +1,4 @@
- NavigatorIOS wraps UIKit navigation and allows you to add back-swipe
+ NavigatorIOS wraps UIKit navigation and allows you to add back-swipe
functionality across your app. A route is an object used to describe each page in the navigator. The first
route is provided to NavigatorIOS as NetInfo exposes info about online/offline status Asyncronously determine if the device is online and on a cellular network. NetInfo exposes info about online/offline status Asyncronously determine if the device is online and on a cellular network. One of React Native's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example. 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's goals is to be a playground where we can experiment with different architectures and crazy ideas. Since browsers are not flexible enough, we had no choice but to reimplement the entire stack. In the places that we did not intend to change anything, we tried to be as faithful as possible to the browser APIs. The networking stack is a great example. 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. It provides a predictable wrapper of the responder handlers provided by the
gesture responder system.
diff --git a/docs/pickerios.html b/docs/pickerios.html
index e7e5888d550..6a57265b31e 100644
--- a/docs/pickerios.html
+++ b/docs/pickerios.html
@@ -1,4 +1,4 @@
- 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 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
diff --git a/docs/pushnotificationios.html b/docs/pushnotificationios.html
index 9eed91e5e49..bd994c496aa 100644
--- a/docs/pushnotificationios.html
+++ b/docs/pushnotificationios.html
@@ -1,4 +1,4 @@
-Libraries folder in
diff --git a/docs/linkingios.html b/docs/linkingios.html
index fee2d790550..9b4f04ae276 100644
--- a/docs/linkingios.html
+++ b/docs/linkingios.html
@@ -1,4 +1,4 @@
-LinkingIOS
LinkingIOS gives you a general interface to interact with both, incoming
+LinkingIOS
LinkingIOS gives you a general interface to interact with both, incoming
and outgoing app links.Basic Usage #
Handling deep links #
ListView
ListView
ListView.DataSource, populate it with a simple array of data blobs, and
instantiate a ListView component with that data source and a renderRow
diff --git a/docs/mapview.html b/docs/mapview.html
index fb022d886eb..fb1a7f3af07 100644
--- a/docs/mapview.html
+++ b/docs/mapview.html
@@ -1,4 +1,4 @@
-MapView
Edit on GitHubProps #
annotations [{latitude: number, longitude: number, title: string, subtitle: string}] #
legalLabelInsets {top: number, left: number, bottom: number, right: number} #
MapView
Edit on GitHubProps #
annotations [{latitude: number, longitude: number, title: string, subtitle: string}] #
legalLabelInsets {top: number, left: number, bottom: number, right: number} #
EdgeInsetsPropType.js for more information.maxDelta number #
minDelta number #
onRegionChange function #
onRegionChangeComplete function #
pitchEnabled bool #
true and a valid camera is associated
with the map, the camera’s pitch angle is used to tilt the plane
of the map. When this property is set to false, the camera’s pitch
diff --git a/docs/nativecomponentsios.html b/docs/nativecomponentsios.html
new file mode 100644
index 00000000000..0700baed4fb
--- /dev/null
+++ b/docs/nativecomponentsios.html
@@ -0,0 +1,241 @@
+Native UI Components (iOS)
ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.MapView component available in the core React Native library.iOS MapView example #
MKMapView, we just need to make it usable from JavaScript.RCTViewManager. These subclasses are similar in function to view controllers, but are essentially singletons - only one instance of each is created by the bridge. They vend native views to the RCTUIManager, which delegates back to them to set and update the properties of the views as necessary. The RCTViewManagers are also typically the delegates for the views, sending events back to JavaScript via the bridge.RCT_EXPORT_MODULE() marker macro.
+- Implement the -(UIView *)view methodProperties #
BOOL - React Native uses RCTConvert under the hood to convert all sorts of different data types when talking over the bridge, and bad values will show convenient "RedBox" errors to let you know there is an issue ASAP. When things are straightforward like this, the whole implementation is taken care of for you by this macro.PropTypes:requireNativeComponent from null to the new MapView wrapper component. This allows the infrastructure to verify that the propTypes match the native props to reduce the chances of mismatches between the ObjC and JS code.region prop. We start by adding the native code:BOOL case we had before. Now we have a MKCoordinateRegion type that needs a conversion function, and we have custom code so that the view will animate when we set the region from JS. There is also a defaultView that we use to reset the property back to the default value if JS sends us a null sentinel.MKCoordinateRegion via two categories on RCTConvert:region prop, we need to document it in propTypes (or we'll get an error that the native prop is undocumented), then we can set it just like any other prop:Events #
RCTMapManager a delegate for all the views it vends, and forward the events to JS via the event dispatcher. This looks like so (simplified from the full implementation):-mapView:regionDidChangeAnimated: the region is combined with the reactTag target to make an event that is dispatched to the corresponding React component instance in your application via sendInputEventWithName:body:. The event name @"topChange" maps to the onChange callback prop in JavaScript (mappings are here). This callback is invoked with the raw event, which we typically process in the wrapper component to make a simpler API:Styles #
UIView, most style attributes will work like you would expect out of the box. Some components will want a default style, however, for example UIDatePicker which is a fixed size. This default style is important for the layout algorithm to work as expected, but we also want to be able to override the default style when using the component. DatePickerIOS does this by wrapping the native component in an extra view, which has flexible styling, and using a fixed style (which is generated with constants passed in from native) on the inner native component:RCTDatePickerIOSConsts constants are exported from native by grabbing the actual frame of the native component like so:RCTMapManager and other components in the source code.Native Modules (iOS)
iOS Calendar module example #
RCTBridgeModule protocol. If you are wondering, RCT is a shorthand for ReaCT.Native Modules (iOS)
iOS Calendar Module Example #
RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.RCTBridgeModule protocol, your class must also include the RCT_EXPORT_MODULE() macro. This takes an optional argument that specifies the name that the module will accessed by in your JavaScript code (more on this later). If you do not specify a name, the JavaScript module name will match the Objective-C class name.RCTBridgeModule protocol, your class must also include the RCT_EXPORT_MODULE() macro. This takes an optional argument that specifies the name that the module will be accessible as in your JavaScript code (more on this later). If you do not specify a name, the JavaScript module name will match the Objective-C class name.RCT_REMAP_METHOD() to specify the JavaScript method's name. This is useful when multiple native methods are the same up to the first colon and would have conflicting JavaScript names.void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).Argument types #
RCT_EXPORT_METHOD supports all standard JSON object types, such as: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)RCTConvert class (see RCTConvert for details). The RCTConvert helper functions all accept a JSON value as input and map it to a native Objective-C type or class. CalendarManager example, we to pass the event date to the native method. We can't send JavaScript Date objects over the bridge, so we need to convert the date to a string or number. We could write our native function like this:RCT_REMAP_METHOD() to specify the JavaScript method's name. This is useful when multiple native methods are the same up to the first colon and would have conflicting JavaScript names.void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).Argument Types #
RCT_EXPORT_METHOD supports all standard JSON object types, such as: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)RCTConvert class (see RCTConvert for details). The RCTConvert helper functions all accept a JSON value as input and map it to a native Objective-C type or class.CalendarManager example, we need to pass the event date to the native method. We can't send JavaScript Date objects over the bridge, so we need to convert the date to a string or number. We could write our native function like this: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:NSDate. A bad value, like an Array, would generate a helpful "RedBox" error message.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:NSArray containing a mix of NSNumber and NSString. For arrays, RCTConvert provides some typed collections you can use in your method declaration, such as NSStringArray, or UIColorArray. For maps, it is the developer's responsibility to check the value types individually by manually calling RCTConvert helper methods.Callbacks #
NSArray containing a mix of NSNumber and NSString. For arrays, RCTConvert provides some typed collections you can use in your method declaration, such as NSStringArray, or UIColorArray. For maps, it is the developer's responsibility to check the value types individually by manually calling RCTConvert helper methods.Callbacks #
RCTResponseSenderBlock accepts only one argument - an array of arguments to pass to the 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.RCTResponseSenderBlock accepts only one argument - an array of parameters to pass to the JavaScript callback. In this case we use node's convention to make the first parameter an error object (usually null when there is no error) and the rest are the results of the function.RCTAlertManager.RCTMakeError from RCTUtils.h.Implementing a native module #
RCTAlertManager for an example.RCTMakeError from RCTUtils.h. Right now this just passes an Error-shaped dictionary to JavaScript, but we would like to automatically generate real JavaScript Error objects in the future.Threading #
- (dispatch_queue_t)methodQueue method allows the native module to specify which queue its methods should be run on. For example, if it needs to use a main-thread-only iOS API, it should specify this via:dispatch_async to schedule expensive work on background queue.Exporting constants #
RCTAsyncLocalStorage module creates it's own queue so the React queue isn't blocked waiting on potentially slow disk access:Exporting Constants #
constantsToExport value at runtime it won't affect JavaScript environment.Sending events to JavaScript #
eventDispatcher:constantsToExport values at runtime it won't affect the JavaScript environment.Sending Events to JavaScript #
eventDispatcher:RCTLocationObserver.Navigator
Navigator to transition between different scenes in your app. To
+Navigator
Navigator to transition between different scenes in your app. To
accomplish this, provide route objects to the navigator to identify each
scene, and also a renderScene function that the navigator can use to
render the scene for a given route.NavigatorIOS
NavigatorIOS
Routes #
initialRoute:NetInfo
reachabilityIOS #
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 unknownNetInfo
reachabilityIOS #
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 unknownNetwork
XMLHttpRequest #
Network
XMLHttpRequest #
PanResponder
PanResponder reconciles several touches into a single gesture. It makes
+PanResponder
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.PickerIOS
Edit on GitHubProps #
Edit on GitHubExamples #
PickerIOS
Edit on GitHubProps #
Edit on GitHubExamples #
PixelRatio
Displaying a line that's as thin as the device permits #
PixelRatio
Displaying a line that's as thin as the device permits #
1 / PixelRatio.get(). It's a technique that works
on all the devices independent of their pixel density.Fetching a correctly sized image #