Summary: There is no point in returning empty block here. It's a tiny bit wasteful and prevents us from knowing if there are any UI updates.
Depends on D2571122 (not really).
public
Reviewed By: jspahrsummers
Differential Revision: D2571137
fb-gh-sync-id: 4a872f33f05eaf2d858009aa04ea89feaa23576c
Summary: public
Use arrays instead of dictionaries for encoding module method information.
This further reduces UIExplorer startup JSON from 16104 bytes to 14119 (12% reduction)
Reviewed By: javache
Differential Revision: D2570057
fb-gh-sync-id: 4a53a9ead4365a136e7caeb650375733e1c24c0e
Summary: public
This has been broken for a while. The styles in the JS were being set on the container instead of the activity view itself.
Also, due to the way frames were set directly on layer properties instead of the view, resizing didn't work properly because the UIImageView inside the UIActivityView was not being realligned when the bounds changed. This also caused problems for other controls such as maps, where it was fixed with a method override, but the simpler solution is just to set the view center and bounds directly.
Before: {F23631143}
After: {F23631144}
Reviewed By: javache, tadeuzagallo
Differential Revision: D2575156
fb-gh-sync-id: e82e56d36648e7c924df77da1750e03037b5d5be
Summary: Set up the polyfills for console and process before initializing other modules. Some modules do work (e.g. call `invariant`) when they are first required, so requiring the DefaultInjection module at the beginning ensures we have a consistent JS environment.
Closes https://github.com/facebook/react-native/pull/3526
Reviewed By: spicyj
Differential Revision: D2560340
Pulled By: frantic
fb-gh-sync-id: 44c743e3212ff1dcdbe0169041dfd3ea8f1a54f7
Summary: public
We're sending a lot of module config data when the app first starts, and much of this is redundant.
UIExplorer current sends 19061 bytes of module config JSON. This diff reduces that to 16104 (15% saving) by stripping modules that have no methods or constants, and removing method types unless method is async.
Reviewed By: tadeuzagallo, javache
Differential Revision: D2570010
fb-gh-sync-id: 8c0abbd1cdee3264b37a4f52e852008caaffb9c5
Summary: Right now `FormData` doesn't allow duplicate keys and uses the last value set for a duplicate key. I tested this in Chrome:
```
var formData = new FormData();
formData.append('key', 'value1');
formData.append('key', 'value2');
var request = new XMLHttpRequest();
request.open("POST", serverUrl);
request.send(formData);
```
and the request has both 'value1' and 'value2'.
I removed the duplicate key check in `FormData`. If people want to build appending or disallow duplicate keys, they can build either on top of this.
Closes https://github.com/facebook/react-native/pull/3556
Reviewed By: svcscm
Differential Revision: D2566999
Pulled By: nicklockwood
fb-gh-sync-id: 580e52e69376ebe9693e39a386cc540802b6d94f
Summary: public
UIActionSheet no longer works on iPad when building with the iOS 9 SDK, as reported here: https://github.com/facebook/react-native/issues/3498
This diff implements an alernative code path that uses UIAlertController instead when its available.
Also added `anchor` support for action sheets (previously only supported for share sheet).
Reviewed By: javache
Differential Revision: D2560068
fb-gh-sync-id: feda20f6f1fee5e2ba624761fbeb812e23d96fff
Summary: The first change is to remove the word 'Hybrid' to a lot of javascript developers the word Hybrid is normally referred to as a webview app (such as Cordova) and this may cause confusion.
The second change is to refer to the property within Navigator that allows a scene to be presented from the bottom of the screen (like a modal).
Closes https://github.com/facebook/react-native/pull/3173
Reviewed By: svcscm
Differential Revision: D2561886
Pulled By: javache
fb-gh-sync-id: e37e5d06869ffadc152abaf304f77c93b81f71a3
Summary: public
In Navigator, there are several places that mutate `this.state.presentedIndex`
with the express `this.state.presentedIndex = destIndex` instead of calling
`this.setState`, which creates the problem that not all internal states are
updated within the same React update cycle.
One of the symptoms is that over-swiping within the Navigator may throw JS error
due to `this.state.sceneConfigStack` and `this.state.presentedIndex` are not both
updated.
The workaround is to bypass the over-swiping gesture to avoid JS error.
Reviewed By: ericvicenti
Differential Revision: D2557140
fb-gh-sync-id: 1e5c9047ed17c04a63e2a568118848b00723fb1d
Summary: public
The image loader was previously returning on the main thread, which could lead to poor performance due to various call sites doing further image processing (resizing, cropping, etc.) directly in the completion block.
This diff modifies the loader to return on a background thread (the same one used to load the image), and updates the call sites to dispatch to the explicit thread they need.
Reviewed By: javache
Differential Revision: D2549774
fb-gh-sync-id: fed73b7c163fdf67ff65bae72ab1986327e75815
Summary: public
If the frame is set, or the image view moves to a window, we should attempt to load the "real" image. The sizing logic shouldn't kick in if we're only displaying the default image.
Resolves https://github.com/facebook/react-native/issues/3460.
Reviewed By: tadeuzagallo
Differential Revision: D2555316
fb-gh-sync-id: c0c13070ee080bad2b30ca01d9d5173bead406e3
Summary: Adds the API that enables the navigation events capturing and bubbling which is the feature
that is enabled if the nested navigation contexts is created by the navigator.
This would allow developer to observe or reconcile navigation events within the navigation tree.
public
./Libraries/FBReactKit/jest
Reviewed By: zjj010104
Differential Revision: D2546451
fb-gh-sync-id: dfc9d16defaa563b9e80fd751a20570f6e524b74
Summary: public
Added RCTDataRequestHandler, which is responsible for loading data URLs. This moves the logic for data URL handling out of RCTImageDownloader (no longer needed) and into the RCTNetwork library, where it makes more sense.
This also means that it is now possible to load data URLs via XHR, and use them for purposes other than just images.
Reviewed By: javache
Differential Revision: D2540964
fb-gh-sync-id: 4f0418bd6b9186f047cc8297276bb970795af104
Summary: public
There was a race condition issue in RCTDownLoadTask whereby the request handler would sometimes call one of the delegate methods before setup was complete, causing an error to be logged because the request token had not been set, and causing te request to fail because the class was not yet set up.
This diff fixes that issue by adding an explicit `start` method to RCTDownloadTask, and changing the setup order to allow for the request to call back immediately without this being treated as an error.
Reviewed By: tadeuzagallo
Differential Revision: D2553628
fb-gh-sync-id: 5ca4e791574a632ccbf2e873e28ac88bffdf851d
Summary: public
Benchmarking our startup path has shown we spend a lot of time decoding strings (iPhone 4S / iPhone 5):
* reading a 2MB JS bundle: 35ms / 15ms
* decoding is to an `NSString`: 186ms / 78ms
* transforming that to a `JSString`: 29ms / 10ms
Instead of going through an `NSString` transformation, we generate a null-terminated bundle (0.1ms / 0.05ms to copy the data) and use `JSStringCreateWithUTF8CString` (121ms / 53ms) to generate the string. That makes decoding 70% faster.
Reviewed By: javache
Differential Revision: D2541140
fb-gh-sync-id: 09a016b8edfd46a9b62682c76705564d2024e75e
Summary: Partially fixes#3316 by addressing 16 linter warnings:
- Strings should be singlequote
- Missing semicolon
Travis build jobs 1.1 through 1.4 complete successfully. 1.5 fails through what appears to be an unrelated issue on master.
Closes https://github.com/facebook/react-native/pull/3332
Reviewed By: @svcscm
Differential Revision: D2531718
Pulled By: @javache
fb-gh-sync-id: ca22fbeac5fe3b4f725775a72f21b6dd7a75d94b
Summary: Adds a new option to animation configs so that animations can be marked as non-interactions. This solves the "loading indicator problem" where an animated loading screen would deadlock as it waits for all interactions to complete.
As for the API, what we really want long term is better scheduling. This needs to be built at the runtime level (into the RN bridge) and take care of things like priority donation that are probably overkill right now. Basically this API is a medium-term fix and I won't be upset if it gets replaced with a finer-grained scheduler.
Closes https://github.com/facebook/react-native/pull/3433
Reviewed By: @svcscm
Differential Revision: D2545300
Pulled By: @vjeux
fb-gh-sync-id: c1216bf69bfbbbae00c76c4697183fe96a6a01dd
Summary: Current code is checking presence of touchableGetPressRectOffset method but fails immediately on trying to get 'left' value of null.
Closes https://github.com/facebook/react-native/pull/3438
Reviewed By: @svcscm
Differential Revision: D2545068
Pulled By: @javache
fb-gh-sync-id: d16cb46af1fc6eae02f56b2096c2169ce475e022
Summary: I was just implementing push notifications for my iOS app and was very confused why the `register` event wasn't working.
[Eventually I ran across this tutorial](https://medium.com/@DannyvanderJagt/how-to-use-push-notifications-in-react-native-41e8b14aadae) that explained that I needed to update my AppDelegate to make that event work.
I've updated the documentation to include that note within the actual file.
Closes https://github.com/facebook/react-native/pull/3390
Reviewed By: @svcscm
Differential Revision: D2537853
Pulled By: @javache
fb-gh-sync-id: 1e8860173c38f6b2d7f9d273019f201e4cc9c0f2
Summary: Check that the WS state is set to OPEN before trying to close it when the ```websocketFailed``` event fires. Otherwise the app throws an error at the Android level.
Fixes#3346
Closes https://github.com/facebook/react-native/pull/3347
Reviewed By: @svcscm
Differential Revision: D2535807
Pulled By: @mkonicek
fb-gh-sync-id: bb70c551ea2e582cfaa80139a265dbbca6d990d2
Summary: @public
We previously discovered that using an NSURLSessionDataTask to load local files is noticably less efficient than using regular filesystem methods.
This diff adds RCTFileRequestHandler as a replacement for RCTHTTPRequestHandler when loading local files. This reduces loading time when loading local files via XMLHttpRequest, as well as improving the performance for some image load requests.
Reviewed By: @javache
Differential Revision: D2531710
fb-gh-sync-id: 259714baac131784de494d24939f42ad52bff41a
Summary: Corrected computation of RCText element height with padding (padding was counted twice).
See also issue #2466.
Closes https://github.com/facebook/react-native/pull/2838
Reviewed By: @svcscm
Differential Revision: D2535924
Pulled By: @nicklockwood
fb-gh-sync-id: b9527803c0a5a6eed1db7e37c98b628750ab2045
Summary: @public
The legacy 'isStatic' property for image sources is no longer used anywhere in our codebase, but was still being generated by the packager and referenced in the JS in various places.
This diff removes all the remaining references.
Reviewed By: @frantic
Differential Revision: D2531263
fb-gh-sync-id: 0bba0bb8473b1baa908ef7507cbf6d83efb0d9ee
Summary: @public
Take a step back and de-batch the bridge calls so we can have better profiling data and a better starting point to work on future optimisations. Also gave a 10~15% win on first render.
Reviewed By: @javache
Differential Revision: D2493674
fb-gh-sync-id: 05165fdd00645bdf43e844bb0c4300a2f63e7038
Summary: @public
jest is running the polyfill multiple times on the same environment (cc @cpojer, need to fix that!). By default jest doesn't have XMLHttpRequest polyfilled so it'll define a property with writable to be false. It'll fatal the second time it tries to override XMLHttpRequest.
The hacky workaround is to make properties that do not exist with writable: true. But the long term fix would be to make jest stop running the polyfill multiple times.
Reviewed By: @javache
Differential Revision: D2532019
fb-gh-sync-id: a82abf69541781a64a0744798c736f90833e28cb
Summary: This was a confusing place for them. BoundingDimensions, Position, and Touchable were only used in Touchable; StaticContainer I moved to Libraries/Components.
@public
Reviewed By: @vjeux
Differential Revision: D2530730
fb-gh-sync-id: e636a6b7259c2bd3ab52c82ebd59a6c66c9e7e7a
Summary: @public
This diff unifies the logic for detecting when images refer to XCAsset files into a single function (RCTXCAssetNameForURL) and uses it for both +[RCTConvert UIImage:] and RCTImageLoader.
I've also tightened the definition of XCAssets so that it only applies to images inside .car files, not any image inside the main bundle. This avoids using the +[UIImage imageNamed:] when not strictly necessary, which is desirable since that method is not thread-safe, and has undocumented caching behavior that is difficult to reason about.
Reviewed By: @javache
Differential Revision: D2526400
fb-gh-sync-id: 7199c2a44f1d55ff236d2c38a0a9368739b993d5
Summary: This allows for the iOS-style navigation bar on Android and vice versa in order to simplify design. It is entirely optional in that NavigationBars will continue to defauly to their platform-specific style, but you can override it with the `navigationStyles` prop:
```js
<Navigator.NavigationBar
navigationStyles={Navigator.NavigationBar.StylesIOS}
/>
```
Fixes#2995.
Closes https://github.com/facebook/react-native/pull/3028
Reviewed By: @svcscm
Differential Revision: D2527902
Pulled By: @ericvicenti
fb-gh-sync-id: c7b1bfac200b5e03fc0d9dfb8acc8b916c825595
Summary: The most common cases is either that nothing changed or that only one part of
an array changed.
@public
Reviewed By: @spicyj
Differential Revision: D2516385
fb-gh-sync-id: 0cd09b95ebac37ee1b575025d23ae2f2e6e2fb47
Summary: @kmagiera @mkonicek - made a mistake while updating it, removed the `margin` style for some reason on the inner Text (it was 1am, ¯\_(ツ)_/¯). This also makes the example nicer looking - style the navigation with a white background, center the text in the main content view.
![](http://url.brentvatne.ca/16xXe.png)
![](http://url.brentvatne.ca/1a4Jt.png)
Closes https://github.com/facebook/react-native/pull/2682
Reviewed By: @svcscm
Differential Revision: D2454465
Pulled By: @mkonicek
fb-gh-sync-id: 2fa17366b34ae31c490d37791ad693c17ac3f128
Summary: @public
This diff implements inline image support for <Text> nodes. Images are specified using <Image> tags, however all properties of the image are currently ignored apart from the source (including width/height styles).
Images are loaded asyncronously, and will trigger a text re-layout when they have loaded.
Reviewed By: @javache
Differential Revision: D2507725
fb-gh-sync-id: 59d0696d00a1bc531915cc35242a16b2dec96e85
Summary: This is related to the discussion in #3155.
I've documented the methods in this mixin, and pointed to other appropriate documentation where necessary as well.
I didn't end up adding any examples. I wanted to add a `focus()`/`blur()` example to the UIExplorer app, but the app seems to be broken on master at the moment (`Requiring unknown module "event-target-shim"`) and I didn't bother trying to fix it. I think the last thing necessary for making the usage of these methods clear is an example of calling one or more of them on a `ref` or view captured in some other way. However, `setNativeProps` is well documented in the "Direct Manipulation" guide, which I link to from this page, so by extension it should be possible to figure out the functionality of the other methods.
cc @mkonicek @astreet
Closes https://github.com/facebook/react-native/pull/3238
Reviewed By: @svcscm
Differential Revision: D2517187
Pulled By: @mkonicek
fb-gh-sync-id: 4e68b2bc44ace83f06ae2e364ca0c23a7c461b20
Summary: The JavaScript code for Android is same as the iOS counterpart, I just added few new lines and used arrow functions instead of binding `this`.
Closes https://github.com/facebook/react-native/pull/2839
Reviewed By: @svcscm, @vjeux
Differential Revision: D2498703
Pulled By: @mkonicek
fb-gh-sync-id: 3fe958dd5af0efba00df07515f8e33b5d87eb05b
Summary: These were accidentally supported because they were merged at a lower
level. That's an implementation detail. setNativeProps should still
normalize the API.
I fixed some callers.
Setting props the normal way used to ignore these. Unfortunately we can't
warn for those cases because lots of extra props are spread. (The classic
transferPropsTo issue.)
@public
Reviewed By: @vjeux
Differential Revision: D2514228
fb-gh-sync-id: 00ed6073827dc1924da20f3d80cbdf68d8a8a8fc
Summary: Decouple processStyle from the main reconciliation. It is now a process
extension to the style attribute `transform`. This effectively decouples a
large portion of special cases and helper dependencies from the reconciler.
The transform attribute becomes translated into the transformMatrix attribute on
the native side so this becomes a little weird in that I have to special case
it. I don't think it is worth while having a general solution for this so I
intend to rename the native attribute to `transform` and just have it accept the
resolved transform. Then I can remove the special cases.
The next step is generalizing the flattenStyle function and optimizing it.
@public
Reviewed By: @vjeux
Differential Revision: D2460465
fb-gh-sync-id: 243e7fd77d282b401bc2c028aec8d57f24522a8e
Summary: Move the ViewAttributes and StyleAttributes configuration into the
Components library since they're coupled and change with the
native component configuration.
This also decouples StyleAttributes from the reconciler by adding it
to the ReactViewAttributes.
To do that, I refactored the property diffing to allow for recursive
configurations. Now an attribute configuration can be a nested object,
a custom configuration (diff/process) or true.
The requireNativeComponent path incorrectly gets its attributes set up
on the root validAttributes instead of the nested style object.
So I also have to add the nested form. Effectively these currently allow
these attributes on props or nested.
@public
Reviewed By: @vjeux
Differential Revision: D2456842
fb-gh-sync-id: cd5405bd8316c2fcb016d06c61244ce7719c26c0
Summary: Concolidate the creation of the "update payload" into
ReactNativeAttributePayload which now has a create
and a diff version. The create version can be used by
both mountComponent and setNativeProps. This means that
diffRawProperties moves into ReactNativeAttributePayload.
Instead of storing previousFlattenedStyle as memoized
state in the component tree, I recalculate it every
time. This allows better use of the generational GC.
However, it is still probably a fairly expensive
technique so I will follow it up with a diff that
walks both nested array trees to do the diffing in a
follow up.
This is the first diff of several steps.
@public
Reviewed By: @vjeux
Differential Revision: D2440644
fb-gh-sync-id: 1d0da4f6e2bf716f33e119df947c044abb918471
Summary: @public
UIManagerStatTracker now provides allTime and perBatch stats so it's easy to see
how bit each batch is.
Reviewed By: @vjeux
Differential Revision: D2506218
fb-gh-sync-id: 635556185245d2bd6cb149497ea60b503b2523ce
Summary: @public
Sometimes we want to load a very small number of rows initially and want the
onEndReached callback to be called immediately to trigger more data to be
loaded without waiting for the user to scroll at all. This diff makes that
happen by also checking on mount instead of only when scrolling.
Reviewed By: @vjeux
Differential Revision: D2507184
fb-gh-sync-id: ea8e47667d00387a935a426dd45afe978fd6d8cd
Summary: 1. Should I add an example of this to the UIExplorer Animation example?
2. Should I support mixing hex and rgba values in outputRange? It is possible with this implementation, but may cause confusion
Closes https://github.com/facebook/react-native/pull/3177
Reviewed By: @svcscm
Differential Revision: D2506947
Pulled By: @vjeux
Summary: The StyleSheet merging algorithm was modeled after `Object.assign` and the native spread operator. This diff converts `flattenStyle` to actually use `Object.assign`.
Closes https://github.com/facebook/react-native/pull/3048
Reviewed By: @svcscm
Differential Revision: D2506387
Pulled By: @vjeux
Summary: @public
Jest has an issue where if you export `Symbol` it crashes badly. Since event-target-shim does that, it breaks everything. Mocking that module fixes the issue until @cpojer comes back from vacation and fixes the bug in Jest itself.
Reviewed By: @jingc
Differential Revision: D2503562
Summary: I previously added this check to make the test complete waits until all teardown completed but if you're running tests with any other executor than the JSC one, this would crash.
@public
Reviewed By: @jspahrsummers
Differential Revision: D2493967
Summary: * wrap code snippet in TextInput Comment in backticks ```
* unless there is a way to omit portions of comments from reaching the
docs this is less confusingCloses https://github.com/facebook/react-native/pull/3085
Reviewed By: @svcscm
Differential Revision: D2495630
Pulled By: @frantic
Summary: **Problem**
Using push notifications in IOS 8 will throw this error:
`registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.`
The problem is that the check is running on compile instead of runtime.
**Solution**
If have changed the compile if statement to a runtime if statement. The fix is tested on: IOS 7.1 and 8.* and everything is working now.
This solution is also discussed in: https://github.com/facebook/react-native/issues/1613 and it was part of https://github.com/facebook/react-native/pull/1979. (is being separated to keep things moving)
Please let me know what you think.Closes https://github.com/facebook/react-native/pull/2332
Reviewed By: @svcscm
Differential Revision: D2490987
Pulled By: @ericvicenti
Summary: When `RCTImageView` is removed from the view hierarchy, it clears out its `image` to save memory. This makes sense, except that it gets removed from the window (view hierarchy) even when becoming the child of another view.
This fixes the logic so that it only clears out the image if the view hasn't been moved somewhere else within one frame.
@public
Reviewed By: @javache
Differential Revision: D2493849