Commit Graph

970 Commits

Author SHA1 Message Date
Alex Kotliarskyi e2b25c8c9d Add multipart response stream reader
Summary:
Packager can take a long time to load and the progress is usually displayed in another window (Terminal). I'm adding support for showing a UI inside React Native app for packager's progress when loading a bundle.

This is how it will work:

1. React Native sends request to packager with `Accept: multipart/mixed` header.
2. Packager will detect that header to detect that client supports progress events and will reply with `Content-Type: multipart/mixed`.
3. While building the bundle it will emit chunks with small metadata (like `{progress: 0.3}`). In the end it will send the last chunk with the content of the bundle.
4. RN runtime will be receiving the events, for each progress event it will update the UI. The last chunk will be the actual bundle which will end the download process.

This workflow is totally backwards-compatible -- normally RN doesn't set the `Accept` header.

Reviewed By: mmmulani

Differential Revision: D3845684

fbshipit-source-id: 5b3d2c5a4c6f4718d7e5de060d98f17491e82aba
2016-10-03 18:13:36 -07:00
Andrei Coman 17405b9774 Fix image example
Summary: Bundled images is ios only, legacy image was not present in android resources.

Reviewed By: javache

Differential Revision: D3930349

fbshipit-source-id: 663019351615b173621ef27dbf67ec595f8a590f
2016-09-29 07:28:55 -07:00
Douglas Lowder d368ebfab2 Apple TV support 1: existing Objective C code should compile for tvOS
Summary:
First commit for Apple TV support: changes to existing Objective-C code so that it will compile correctly for tvOS.
Closes https://github.com/facebook/react-native/pull/9649

Differential Revision: D3916021

Pulled By: javache

fbshipit-source-id: 34acc9daf3efff835ffe38c43ba5d4098a02c830
2016-09-27 06:28:33 -07:00
Pieter De Baets 339531065f Fix some linter warnings
Reviewed By: majak

Differential Revision: D3930059

fbshipit-source-id: dbbf67f287c46535f9c5947cd7ac101c5c91615e
2016-09-27 06:13:31 -07:00
Emil Sjolander b644b426af Fix RN instrumentation tests
Reviewed By: bestander

Differential Revision: D3924964

fbshipit-source-id: 8f925d4239ea3471bc3984ea05d48a5cd1b96f5a
2016-09-26 11:58:35 -07:00
Mehdi Mulani 820b1c0e46 Add partial image loading to RCTImageView
Reviewed By: javache

Differential Revision: D3856918

fbshipit-source-id: ca98f8604213e7e583a188ccc4c25ea9d7aa9aa2
2016-09-21 12:14:09 -07:00
Janic Duplessis 6565929358 Add support for animated events
Summary:
This adds support for `Animated.event` driven natively. This is WIP and would like feedback on how this is implemented.

At the moment, it works by providing a mapping between a view tag, an event name, an event path and an animated value when a view has a prop with a `AnimatedEvent` object. Then we can hook into `EventDispatcher`, check for events that target our view + event name and update the animated value using the event path.

For now it works with the onScroll event but it should be generic enough to work with anything.
Closes https://github.com/facebook/react-native/pull/9253

Differential Revision: D3759844

Pulled By: foghina

fbshipit-source-id: 86989c705847955bd65e6cf5a7d572ec7ccd3eb4
2016-09-19 04:14:01 -07:00
leeight e193aea2f4 FIX #9939 - Add missing options argument to Android picker example
Summary:
`options` is required when call `TimePickerAndroid.open()`
Closes https://github.com/facebook/react-native/pull/9940

Differential Revision: D3876076

fbshipit-source-id: 58c017d2a7acdc3d584bcc7ef965b56170a1594b
2016-09-16 00:43:30 -07:00
Janic Duplessis d0d1712851 Reverted commit D3827366
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

Pulled By: fred2028

fbshipit-source-id: d346068734c5b987518794ab23e13914ed13b5c4
2016-09-15 12:13:39 -07:00
Neo c1ed6ab4ed add missing uiexplorer examples on android
Summary:
since #9456 has been landed, it's the time to add ListViewPagingExample to the example list for Android
Closes https://github.com/facebook/react-native/pull/9930

Differential Revision: D3871517

fbshipit-source-id: dafa8ab2d704bcc5e7bc25b5fcec18a1a6cfa28a
2016-09-15 11:58:36 -07:00
Pieter De Baets 00e7d46df3 Improve stability of RCTAllocationTests
Reviewed By: frantic

Differential Revision: D3862884

fbshipit-source-id: 52b168c62facd8e67d7047a087c843f3c477ca58
2016-09-15 04:28:47 -07:00
Janic Duplessis 0e8b75b22c Implement ScrollView sticky headers on Android
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

fbshipit-source-id: cab044cfdbe2ccb98e1ecd3e02ed3ceaa253eb78
2016-09-14 20:43:29 -07:00
Satyajit Sahoo 3e153b2a5b Remove react-native.js.flow
Summary:
We've enabled getters in .flowconfig, so Flow will now understand react-native.js. We no longer need to maintain a separate file for Flow.

cc bestander
Closes https://github.com/facebook/react-native/pull/9892

Differential Revision: D3862560

Pulled By: bestander

fbshipit-source-id: 9efb66bc885dbac80c18b4b5e3cf5362495928a9
2016-09-14 02:58:40 -07:00
Janic Duplessis f3253c0f84 Fix UIExplorer search bar look on Android
Summary:
Remove the underline color of the TextInput so the search input looks the same as iOS. Also add a missing type import.

Before
![image](https://cloud.githubusercontent.com/assets/2677334/18487095/e91b8066-79c1-11e6-82c8-adb3f86bc278.png)

After:
![image](https://cloud.githubusercontent.com/assets/2677334/18487043/b457987e-79c1-11e6-9393-e98d78556ef2.png)
Closes https://github.com/facebook/react-native/pull/9889

Differential Revision: D3858957

fbshipit-source-id: 322fd391ef055c742f5dd8f324a9b45965eb278f
2016-09-13 17:28:34 -07:00
Jacob Parker 9e6e573e19 NavigatorIOS System Icon Support
Summary:
Continuation on #3959 (started by cancan101). Rebased to latest master, adds support for left system icon, fixes issues mentioned in previous PR.

<img width="432" alt="screen shot 2016-09-05 at 13 54 41" src="https://cloud.githubusercontent.com/assets/7275322/18248478/5b7aa25c-7370-11e6-8c51-01a2b7fd1030.png">
Closes https://github.com/facebook/react-native/pull/9742

Differential Revision: D3836850

Pulled By: javache

fbshipit-source-id: ef9f6e42211ed18bf5f3dc1eb7a8b1318d939674
2016-09-08 17:58:50 -07:00
Alex Kotliarskyi f1c158e534 Guard against possible race conditions in RCTAllocationTests
Reviewed By: javache

Differential Revision: D3829341

fbshipit-source-id: 2a3fd66a7b1494176726a79ef28cef5158d8ad58
2016-09-08 15:13:35 -07:00
Mehdi Mulani de3457f31d Allow <Modal /> to be presented in different orientations
Reviewed By: javache

Differential Revision: D3760002

fbshipit-source-id: 01f5c246fb0fc041ec2d63b4ef80de858fb6fdf2
2016-09-07 13:10:11 -07:00
Spencer Ahrens 322c160fb1 Add some stall stuff as settings to native animated example
Reviewed By: fkgozali

Differential Revision: D3817885

fbshipit-source-id: 047f806411982aafdf7420eebadff063f56fee69
2016-09-06 19:58:35 -07:00
Spencer Ahrens fab0ff35f1 Introduce UIExplorerStatePersister and use for search filter
Reviewed By: fkgozali

Differential Revision: D3817864

fbshipit-source-id: 55ca7cc66b53714d881c0593d5441d2ad1e44207
2016-09-06 14:58:31 -07:00
Spencer Ahrens 2554f26387 Fix CameraRollExample crash
Reviewed By: fkgozali

Differential Revision: D3817912

fbshipit-source-id: f3c83675d06149a1e027b9ccd33d3c6cde234be3
2016-09-06 14:43:46 -07:00
Spencer Ahrens e2d84a8221 small cleanup in RTLExample
Reviewed By: fkgozali

Differential Revision: D3817896

fbshipit-source-id: c47f91f4b59e0d3964faa41ad6d7dbce61e7140a
2016-09-06 14:43:46 -07:00
Ian MacLeod 4f89fa9cf3 registration error event
Summary:
This is an updated version of #2336 and #7694.

 ---

This adds a `registrationError` event that is emitted by `PushNotificationIOS` whenever an application receives a registration error from APNS (APNS service failure, running on simulator, etc).  This event fires to the exclusion of the `register` event (and vice versa).

**How to use**

Add the following to your `AppDelegate.m`:

```obj-c
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
```

And register an event handler for the event:

```js
PushNotificationIOS.addEventListener('registrationError', function({ message, code }) {
  // Complete your registration process in error.
});
```

**Test plan**

Added support for this event (and `register`) to UIExplorer as a proof of concept.  Navigating to the push notifications example on a simulator is an easy way to reproduce this e
Closes https://github.com/facebook/react-native/pull/9650

Differential Revision: D3822142

Pulled By: javache

fbshipit-source-id: a15ed8941b74dc3eed2c44c658deccbcaf39ce3d
2016-09-06 11:13:40 -07:00
Andrei Coman 128b698a03 UIExplorer fixes
Summary:
Currently, when reloading uiexplorer, it does not go back to the last visited
component. This fixes it, by only storing the state (which contains the last
visited component), after it has been set.

Reviewed By: bestander

Differential Revision: D3821288

fbshipit-source-id: 5b9ba10765ce402c20016519a3b7f6b5211cc623
2016-09-06 06:43:37 -07:00
leeight 0d176b3337 Update XHRExampleFetch and dump the response headers
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

> **Unless you are a React Native release maintainer and cherry-picking an *existing* commit into a current release, ensure your pull request is targeting the `master` React Native branch.**

Dump the response headers so that we can check `Set-Cookie` header is working properly whether or not.

**Test plan (required)**

Manual Test.

![image](https://cloud.githubusercontent.com/assets/104052/18259326/6b86c90a-7415-11e6-8979-92bd24ac703c.png)

**Code formatting**

Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).

For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests).
Closes https://github.com/facebook/react-native/pull/9687

Differential Revision: D3821145

Pulled By: javache

fbshipit-source-id: 24baa051165d3b451ba0e71efbe70db44b0bf45e
2016-09-06 04:28:38 -07:00
Andrei Coman f07ca31303 Listen to device orientation changes
Summary:
Similar to iOS, send device orientation changes events. This does not have the
`getCurrentOrientation` method, because it's not used. If necessary, we'll
add it separately.
This also adds a simple example for testing.

We listen to orientation changes in `onGlobalLayout`, and check if the rotation of the device has changed. If it has, we emit the event.
But:
- `onGlobalLayout` (and `onConfigurationChanged` - which is the method usually used for checking for device orientation changes) is *not* called when the device goes from landscape
  to reverse landscape (same with portrait), as that is not a relayout / configuration change. We could detect if this happens with the help of an `OrientationEventListener`. However, this listener notifies you if the degree
  of the phone changes by a single degree, which means that you need to know by how many degrees the phone needs to change in order for the orientation to change. I haven't looked into how accurate this could be, but I suspect that in practice it would cause a lot of bugs. A simple `abgs` and google search reveals that everybody uses a different margin for detecting a rotation change (from 30 to 45 degrees), so I suspect that this won't work
  as expected in practice. Therefore, we're not using this here, and we're sticking to what android provides via `onConfigurationChanged`. If we find that we have issues because users need to know when the user goes
  from landscape to reverse landscape, then we'll have to revisit this.

Reviewed By: foghina

Differential Revision: D3797521

fbshipit-source-id: 62508efd342a9a4b41b42b6138c73553cfdefebc
2016-09-06 03:59:01 -07:00
Andrei Coman 5d240a8ed3 Fix uiexplorer BUCK install
Summary: It's missing a dependency

Reviewed By: bestander

Differential Revision: D3821094

fbshipit-source-id: 8e048f6daa052ff002ebef2498920d7bd69d324d
2016-09-06 03:43:49 -07:00
leeight 99d742c0b7 On Android `geolocationError` return PositionError object.
Summary:
Follow iOS implementation:
https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/RCTLocationObserver.m#L325

and FIX #9710
Closes https://github.com/facebook/react-native/pull/9734

Differential Revision: D3819868

Pulled By: mkonicek

fbshipit-source-id: 3deb7d3d253d402bfcb88c6a94ca705128998748
2016-09-05 12:58:43 -07:00
Pieter De Baets dda3c5f48d Support sync method calls in the objc bridge
Reviewed By: mhorowitz

Differential Revision: D3801188

fbshipit-source-id: b990680049a46840472a25e66882f8a29890ae90
2016-09-05 07:44:00 -07:00
Janic Duplessis 3c1b69c1a9 Add TextInput controlled selection prop on Android
Summary:
Android PR for TextInput selection, based on the iOS implementation in #8958.

** Test plan **
Tested using the text selection example in UIExplorer.
Closes https://github.com/facebook/react-native/pull/8962

Differential Revision: D3819285

Pulled By: andreicoman11

fbshipit-source-id: 9a2408af2a8b694258c88ab5c46322830c71452a
2016-09-05 07:13:46 -07:00
Mehdi Mulani 6c909ef80d Render UIExplorer examples functionally to handle landscape orientation correctly
Reviewed By: javache

Differential Revision: D3810007

fbshipit-source-id: ff8dfa4b326bb385ea91592b374f5a45a6d4ff64
2016-09-02 14:43:44 -07:00
Pieter De Baets 07553d0f1c Update React Native minimum OS version to iOS8
Reviewed By: majak

Differential Revision: D3723143

fbshipit-source-id: 482f9820370b752d937e6df7f74c33d53a0a2e7d
2016-09-01 19:43:47 -07:00
Pieter De Baets 46b54fd7a8 Support bundle argument for image loading
Reviewed By: mmmulani

Differential Revision: D3768798

fbshipit-source-id: 5b35f06957cebfe74aca90fe6a456f7f739509a9
2016-08-31 17:43:49 -07:00
Pieter De Baets 74308209f9 Cleanup FBReactKit BUCK paths
Reviewed By: mmmulani

Differential Revision: D3785232

fbshipit-source-id: 8abb2789420eca9a2f7a88dbf43f2a58ded081c8
2016-08-31 17:43:49 -07:00
Ian MacLeod 63931b1a68 Support RCTNetworking#clearCookies on iOS
Summary:
This adds cookie clearing support for iOS to match the existing support on Android.  Helpful for resetting the app to a clean state (say, when logging a user out).
Closes https://github.com/facebook/react-native/pull/9264

Differential Revision: D3776492

Pulled By: javache

fbshipit-source-id: 59ae19ac09d3cf0d0e229cd9e8e30865e65ca96c
2016-08-26 05:43:39 -07:00
zxcpoiu 2cfe774a56 Ios: complete iOS vibration pattern supports (js)
Summary:
This is a revised follow up version from #8574 ( originally implemented in `objc` )
This PR change the implementation in JS suggested by javache

**motivation**

To supports vibration pattern like android.

The [iOS vibration implementation link](http://stackoverflow.com/questions/12966467/are-there-apis-for-custom-vibrations-in-ios/13047464#13047464) mentioned by skv-headless at https://github.com/facebook/react-native/pull/6061#discussion_r54062592, which will not be accepted by apple since that implementation uses a private API. Thus, I use pure public API `NSTimer` to implement it.

**Note**

Since vibration time on iOS is not configurable, there are slightly differences with android.
for example:

**Android Usage:**
`Vibration.vibrate([0, 500, 200, 500])`
==> V(0.5s) --wait(0.2s)--> V(0.5s)

`Vibration.vibrate([300, 500, 200, 500])`
==> --wait(0.3s)--> V(0.5s) --wait(0.2s)--> V(0.5s)

**iOS Usage:**
if first argument is 0, it will not be included in pattern array.
( vibration
Closes https://github.com/facebook/react-native/pull/9233

Differential Revision: D3775085

Pulled By: javache

fbshipit-source-id: 370495857d5581399de32d2bed1ea1bcce193e9d
2016-08-25 18:28:38 -07:00
Janic Duplessis f0a3c56048 Add TextInput controlled selection prop on iOS
Summary:
This adds support for a controlled `selection` prop on `TextInput` on iOS (Android PR coming soon). This is based on the work by ehd in #2668 which hasn't been updated for a while, kept the original commit and worked on fixing what was missing based on the feedback in the original PR.

What I changed is:
- Make the prop properly controlled by JS
- Add a RCTTextSelection class to map the JS object into and the corresponding RCTConvert category
- Make sure the selection change event is properly triggered when the input is focused
- Cleanup setSelection
- Changed TextInput to use function refs to appease the linter

** Test plan **
Tested using the TextInput selection example in UIExplorer on iOS.
Also tested that it doesn't break Android.
Closes https://github.com/facebook/react-native/pull/8958

Differential Revision: D3771229

Pulled By: javache

fbshipit-source-id: b8ede46b97fb3faf3061bb2dac102160c4b20ce7
2016-08-25 17:28:37 -07:00
Jeff Morrison 5a5c56c8a9 fbsource deploy
Reviewed By: gabelevi, bestander

Differential Revision: D3753032

fbshipit-source-id: 47aadb8a54f47c40f0133966df588d42cdbe0d80
2016-08-23 10:28:53 -07:00
Pieter De Baets 84f68c338a Send down image source to RCTImageView onLoad callback on iOS
Summary: This allows the onLoad callback to know which image has actually loaded. This is only for iOS at the moment - implementing this for Android will require quite a bit more work.

Reviewed By: majak

Differential Revision: D3738759

fbshipit-source-id: b1fc2bd0dc5de90096debeab02b8f795739a4547
2016-08-22 10:58:49 -07:00
Richard Evans 0cf9505630 Allow the disabling of navigation gestures.
Summary:
During development of an app I decided upon NavigationExperimental as I found it easily configurable with my Redux stores and make it work the way I wanted. One thing I found missing was the ability to decide if gestures were on or not for the card stack. In my case I need the gestures off as they conflict with what I am trying to do. This PR simply opens up the ability to turn the gestures for a CardStack off.

Testing was completed via UI Explorer. An additional example replicating the existing one with the new setting set to false was created. To ensure nothing broke I tested both the original example and new example to ensure gestures worked (and didn't work) when expected.

I did not see any unit tests around NavigationExperimental but if I simply missed them I would be more then happy to update/add any.
Closes https://github.com/facebook/react-native/pull/9505

Differential Revision: D3749880

Pulled By: ericvicenti

fbshipit-source-id: dfa42ff8b6c8b41490ad1efc931b364e47058243
2016-08-21 13:13:46 -07:00
Pieter De Baets 049639cfdd Remove unreferenced SliderIOSExample
Reviewed By: foghina

Differential Revision: D3728792

fbshipit-source-id: 879872c9f65af6caa8f027b78a95f718dcc18834
2016-08-19 09:43:40 -07:00
Felix Oghina 2a7f4be8f8 native decay animation
Summary: Add support for `useNativeDriver: true` to `Animated.decay`. Add example in Native Animated Example UIExplorer app.

Reviewed By: ritzau

Differential Revision: D3690127

fbshipit-source-id: eaa5e61293ed174191cec72255ea2677dbaa1757
2016-08-19 07:13:45 -07:00
Mengjue Wang 53d3f94175 Create a RTLExample for OSS
Reviewed By: fkgozali

Differential Revision: D3740559

fbshipit-source-id: 79271abe7ef5c723e934da24884ff777aea0acc3
2016-08-18 20:58:39 -07:00
Martin Kralik ee49dd756d check for NSPhotoLibraryUsageDescription in plist
Reviewed By: javache

Differential Revision: D3723122

fbshipit-source-id: a5393c7dd3c36a15bec3f2e79859920419cc6726
2016-08-18 07:28:43 -07:00
Emil Sjolander fd34c6d567 Move default spacing out of csslayout
Reviewed By: foghina

Differential Revision: D3709574

fbshipit-source-id: 6e0277bd97407a5c642d742f93ca2ac70d7307da
2016-08-18 03:28:34 -07:00
Pieter De Baets a0b3565847 Fix snapshottests under iOS10
Reviewed By: dinhviethoa

Differential Revision: D3722988

fbshipit-source-id: 4345b757e28700ac61e1de38b61430e78948e58a
2016-08-17 10:44:01 -07:00
Pieter De Baets fba96ab990 Use image references consistently in UIExplorer
Reviewed By: davidaurelio

Differential Revision: D3728780

fbshipit-source-id: 4da6a0417eea1ccd0ec0d25574959661f05decb1
2016-08-17 04:43:52 -07:00
Andrei Coman 35d60ecac8 Reinstate view example for screenshot tests
Reviewed By: javache

Differential Revision: D3716630

fbshipit-source-id: 07381f0afe541d0bfea8de6a719d0fa176ccbc3f
2016-08-16 04:58:30 -07:00
Emil Sjolander f7a22bc33c Use single function for margin, position, padding, and border
Reviewed By: lucasr

Differential Revision: D3715201

fbshipit-source-id: ea81ed426f0f7853bb542355c01fc16ae4360238
2016-08-15 09:28:41 -07:00
Connor McEwen 0fb2ccfcc3 Add JS library for requesting Android M Permissions
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

The Android permissions native module was open sourced recently (b7352b4667) but it is currently undocumented and requires directly interfacing with the native module.

This provides a JS wrapper to make it easier to use the permissions module and documents it.

This could be cleaner if the native code used Promise blocks instead of callbacks, but I didn't want to change the native code without a thumbs up since I'm guessing this is used in one of facebook's apps. Happy to do that if it makes sense

I also tried to make the `PERMISSIONS` object a class property - it works in the actual code but not in the documentation (think it's a jsdocs problem), so decided to initialize in the constructor.

**Test plan (required)**

If the API looks good, I will change the UIExplorer example to use this.

cc andreicoman11
Closes https://github.com/facebook/react-native/pull/9292

Differential Revision: D3716303

Pulled By: andreicoman11

fbshipit-source-id: cd40b8757fdf70ea8faecfb58caa00e99a99789e
2016-08-15 05:58:33 -07:00
Janic Duplessis 0e204e1141 Add support for value listener
Summary:
Adds support for `Animated.Value#addListener` for native driven animated values. Same as #8844 but for iOS. This depends on some JS code in #8844 so only review the 2nd commit and let's wait for #8844 to land first.

**Test plan**
Tested using the UIExplorer example.
Closes https://github.com/facebook/react-native/pull/9194

Differential Revision: D3681749

fbshipit-source-id: 521a61e2221c1ad1f6f40c75dd2dc957361d0271
2016-08-11 18:13:31 -07:00