Summary:
Cleans up the documentation and types for `ImageSource`.
The only material changes here are:
- `ImageSource`'s array variant will now be `$ReadOnlyArray` instead of `Array`.
- `ImageURISource.headers` is now an object of string properties.
Changelog:
[General][Changed] - Refined `ImageSource` Flow type for array-variant and headers.
Reviewed By: kacieb
Differential Revision: D23355812
fbshipit-source-id: c3407db037dfb1d3514a028d1a237eb76ee6fedd
Summary:
We disabled animations on Android because native driver animations weren't working yet. After recent changes in NativeAnimatedModule, animations are now working as expected. This diff re-enables animations for bridgeless mode on Android.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D22605612
fbshipit-source-id: 7a7078bf23bb88e7745fc899e1a5ff551425dbad
Summary:
Microsoft’s RN for macOS fork supports the Hermes engine nowadays https://github.com/microsoft/react-native-macos/pull/473. As a longer term work item, we’ve started moving bits that are not invasive for iOS but _are_ a maintenance burden on us—mostly when merging—upstream. Seeing as this one is a recent addition, it seemed like a good candidate to start with.
As to the actual changes, these include:
* Sharing Android’s Hermes executor with the objc side of the codebase.
* Adding a CocoaPods subspec to build the Hermes inspector source and its dependencies (`Folly/Futures`, `libevent`).
* Adding the bits to the Xcode build phase script that creates the JS bundle for release builds to compile Hermes bytecode and source-maps…
* …coincidentally it turns out that the Xcode build phase script did _not_ by default output source-maps for iOS, which is now fixed too.
All of the Hermes bits are automatically enabled, on macOS, when providing the `hermes-engine-darwin` [npm package](https://www.npmjs.com/package/hermes-engine-darwin) and enabling the Hermes pods.
## Changelog
[General] [Added] - Upstream RN macOS Hermes integration bits
Pull Request resolved: https://github.com/facebook/react-native/pull/29748
Test Plan:
Building RNTester for iOS and Android still works as before.
To test the actual changes themselves, you’ll have to use the macOS target in RNTester in the macOS fork, or create a new application from `master`:
<img width="812" alt="Screenshot 2020-08-18 at 16 55 06" src="https://user-images.githubusercontent.com/2320/90547606-160f6480-e18c-11ea-9a98-edbbaa755800.png">
Reviewed By: TheSavior
Differential Revision: D23304618
Pulled By: fkgozali
fbshipit-source-id: 4ef0e0f60d909f3c59f9cfc87c667189df656a3b
Summary:
I noticed when porting my iOS app to macOS via Catalyst that the text rendering was somewhat different on the two platforms. Text looked blurry and over-weight on macOS, even when disabling the Catalyst scaling transform.
I hazily remembered that I'd seen this problem before in my old Cocoa development days: this kind of blurring occurs when rendering text with sub-pixel anti-aliasing into an offscreen buffer which will then be traditionally composited, because when the SPAA algorithm attempts to blend with the underlying content (i.e. in the offscreen buffer), there isn't any. SPAA is disabled on iOS, so the issue wouldn't appear there. On macOS, typical approachs to displaying text (e.g. `CATextLayer`) normally disable SPAA, since it's been incompatible with the platform's compositing strategy since the transition to layer-backed views some years ago. But React Native uses `NSLayoutManager` to rasterize text (rather than relying on the system render server via `CATextLayer`), and that class doesn't touch the context's font smoothing bit before drawing.
This change makes macOS/Catalyst text rendering consistent with iOS text rendering by disabling SPAA.
It appears that the code I've modified is in the process of being refactored (for Fabric?). It looks like [this](8d6b41e9bc/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm (L111)) is the corresponding place in the new code (sammy-SC, is that right?). I'm happy to include a change to the new renderer in this patch if someone can point me at how to test that change.
## Changelog
[iOS] [Fixed] - Improved text rendering on macOS Catalyst
Pull Request resolved: https://github.com/facebook/react-native/pull/29609
Test Plan:
1. Prepare RNTester for running on macOS (or apply [this patch](https://gist.github.com/andymatuschak/d0f5b4fc1a28efc4f860801aa1deddcd) to handle parts 1 and 2, but you'll still need to do part 3):
1. Open the workspace, navigate to the `RNTester` target's configuration, and check the "Mac" checkbox under "Deployment Info.
2. Flipper doesn't yet compile for Catalyst (https://github.com/facebook/react-native/issues/27845), so you must disable it by: a) commenting out `use_flipper!` and `flipper_post_install` in the Podfile, then running `pod install`; and b) removing the `FB_SONARKIT_ENABLED` preprocessor flags in the Xcode project.
3. macOS has different signing rules from iOS; you must set a development team in the "Signing & Capabilities" tab of the `RNTester` target configuration pane. Unfortunately, you must also do this in the `Pods` project for the `React-Core-AccessibilityResources` target ([this is an issue which CocoaPods must fix](https://github.com/CocoaPods/CocoaPods/issues/8891)).
2. Run RNTester with and without the patch. You'll see that the font hinting is overweight without the patch; see screenshots below (incorrect rendering above, correct rendering below; note that fonts still remain slightly blurred because of Catalyst's window scaling transform, but that's removed on Big Sur).
![Screen Shot 2020-08-12 at 10 03 50 AM](https://user-images.githubusercontent.com/2771/90045523-0374c700-dc84-11ea-8945-2d9830bccbd1.png)
![Screen Shot 2020-08-12 at 10 03 15 AM](https://user-images.githubusercontent.com/2771/90045547-0bcd0200-dc84-11ea-88af-37a8879b4efd.png)
Reviewed By: PeteTheHeat
Differential Revision: D23344751
Pulled By: sammy-SC
fbshipit-source-id: 1bbf682b681e381a8a90e152245d9b0df8ec7697
Summary:
Deletes `Animated/polyfills` which is no longer necessary (and only creates extra configuration burden).
Changelog:
[Internal]
Reviewed By: cpojer
Differential Revision: D22451963
fbshipit-source-id: 7a9a48b96b3783f2f6340226bdafd2eaa43f32e7
Summary:
Removes the legacy `react-animated` package configuration and collapses the `Animated/src/` directory into `Animated/`.
Also, reconfigures all references to `Animated/src/` to just be `Animated/`.
Changelog:
[Internal]
Reviewed By: cpojer
Differential Revision: D22450848
fbshipit-source-id: 9fd4861e9f357d817d82e9fec71967a2936a3830
Summary:
Replaces `fbjs/warning` call sites in React Native with `console.warn`. A few warnings will now log as warnings without the "Warning:" prefix.
Changelog:
[General][Changed] - Some warnings changed to use `console.warn` without the "Warning:" prefix.
Reviewed By: TheSavior, cpojer
Differential Revision: D22445946
fbshipit-source-id: 96b01e1bdee52b89ff3b808bc9d6cd494f6787f5
Summary:
This diff ties the stack together. It completes the long chain of RCTSurfacePresenter ownership:
`FBReactModule` -> `RCTNativeAnimatedTurboModule` (this diff and D23272746)
`RCTNativeAnimatedTurboModule` -> `RCTNativeAnimatedNodesManager` (this diff)
`RCTNativeAnimatedNodesManager` -> `RCTPropsAnimatedNode` (D23272735)
It completes animations working without the bridge.
Changelog: [Internal]
Differential Revision: D23272755
fbshipit-source-id: 137f7ff89993a2cb644bd67869eb685afcec4068
Summary:
`RCTPropsAnimatedNode` uses the bridge to access it's current surface presenter to perform animations.
In bridgeless mode, the surface presenter is not owned by the bridge. Instead, pass the surface presenter through the ownership chain:
`RCTNativeAnimated*Module` -> `RCTNativeAnimatedNodesManager` -> `RCTPropsAnimatedNode`
`RCTSurfacePresenter` should not be strongly held by any of these animation internals. If it gets destroyed at a higher level, animations should not be completed.
Changelog: [Internal]
Differential Revision: D23272735
fbshipit-source-id: ce08ee3b59ac2ba70e31cebb7ba8e9f3a644c848
Summary:
The animated native module relies on `setBridge` to perform generic setup which doesn't rely on the bridge at all. This diff refactors that setup code to an `init` function.
Changelog: [Internal]
Differential Revision: D23272427
fbshipit-source-id: 0c9c5522c9044283f4db25360010465ff42aba25
Summary:
Extracts `ScrollViewContext` so that other components can use it without requiring `ScrollView` as a dependency.
Changelog:
[Internal]
Reviewed By: kacieb
Differential Revision: D22670035
fbshipit-source-id: 7f902697ad2a60cd1869438e9a2b77e479a18065
Summary:
This is the JS side of D23010844 (73242b45a9).
In the past I tried a few heuristics to guess when a batch of Animated Operations were ready, and none of these were super reliable. But it turns out we can safely allow JS to manage that explicitly.
Non-Fabric still uses the old behavior which seems fine.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D23010937
fbshipit-source-id: 4a513672c166ceaa8b6daa387e46a2a95b60ce53
Summary:
Every single RN iOS application is initializing this native module on first bundle load, regardless if it is used or not. This wrapperModule makes it lazy.
Changelog: [Internal]
Reviewed By: TheSavior
Differential Revision: D23175668
fbshipit-source-id: 0424a62d6c0b4fe7d5ce95f6c96e641a03b5fb2c
Summary:
Migrating DrawerLayoutAndroid component to use ES6 import
Slowly migrate each file to use es6 import/exports to make this discussion happen
react-native-community/discussions-and-proposals#201 (comment)
## Changelog
[General] [Changed] - Use ES6 import/export syntax for DrawerLayoutAndroid component
Pull Request resolved: https://github.com/facebook/react-native/pull/29639
Test Plan: Manual RNTester for Android
Reviewed By: TheSavior
Differential Revision: D23110137
Pulled By: mdvacca
fbshipit-source-id: a43b4f3981335c9f532185cec8957e46f35aac7b
Summary:
This diff fixes an issue in `TextInput` where `TextInputState.currentlyFocusedInputRef` could maintain a ref to a view that no longer exists. This issue was exposed when upgrading React, where cleanups for passive effects are deferred. This change means that `inputRef.current` would no longer reference the host view *to be* destroyed; it would be null because the view was *already destroyed*.
There are two fixes here that would independently fix the bug and fix the issue better together.
First, we convert `useEffect` to `useLayoutEffect`. `useLayoutEffect` is intended to fire synchronously after all host view mutations, and the cleanup function is intended to fire synchronously before the host view is destroyed, similar to the behavior assumed before. This change is now the correct function to use semantically. However, if we made this change without the second then any change in the order the effects fire would surface the same bug.
So second, move the `inputRefValue).blur()` call to the same effect as unregistering. This is because we currently require the `blur` effect to be called to null out `currentlyFocusedInputRef` in addition to calling `unregisterInput`. That makes the semantic ordering of effects in `TextInput` meaningful. Instead, when a TextInput is unregistered we should always `blur` to clear the `currentlyFocusedInputRef`, which will prevent dispatching events to a view that doesn't exist. If we made this change without the first then there's would be a race condition between calling blur on a TextInput and when that TextInput has been unregistered.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D23035358
fbshipit-source-id: ab686b8046d85e2becd8b879b0b4b7e69e672754
Summary:
Motivation:
`Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).` is an error that happens rarely, and most SO answers end up recommending to use `react-native bundle` to work around. I stumbled upon this error the other day and it took me a while to figure out that the error was caused by the fact that my `entryFile` path was pointing to an existing but invalid file. I figured it would be nice to mention this because I believe this will be a frequent cause of the error.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[General] [Changed] - improve "not a registered callable module error message"
Pull Request resolved: https://github.com/facebook/react-native/pull/28913
Test Plan:
tested locally with RNTester, prints
```
[Sun May 17 2020 18:15:55.396] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). This can happen when the application entry file path is incorrect.
On Android, verify 'getJSMainModuleName()' in 'MainApplication.java' and 'project.ext.react.entryFile' in 'android/app/build.gradle'.
On iOS, verify '- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge' in 'AppDelegate.m' and 'ENTRY_FILE' env. variable passed to 'react-native-xcode.sh' (if any) in 'Build Phases' -> 'Bundle React Native code and images'.
```
in metro logs
Reviewed By: mdvacca
Differential Revision: D23107228
Pulled By: fkgozali
fbshipit-source-id: 0712ed7e593ba96b041578bafdbefcd09a3994b7
Summary:
Previously `reset` was not doing anything about configured callbacks, and after unmount (especially in Fabric) it was possible for callbacks to be called on unmounted nodes due to race conditions.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D23041046
fbshipit-source-id: eb9ebc8e99a0d244a2033e97178bf8ede8b5c7b2
Summary:
In D22801173 (9e6ba9ddb8) I introduced a mechanism to queue Animated operations on the JS side until all mounting effects were finished. I also added an unnecessary check that the NativeAnimated module is loaded, and it seems like if it's called too early, before the NM is initialized, it will crash.
It's not necessary in these two methods, so we just delete the invariant check.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D23040331
fbshipit-source-id: e70ec887695b9abefa0f01408a4a1c2749946d1c
Summary:
In the past I tried a few heuristics to guess when a batch of Animated Operations were ready, and none of these were super reliable. But it turns out we can safely allow JS to manage that explicitly.
Non-Fabric still uses the old behavior which seems fine.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D23010844
fbshipit-source-id: 4c688d3a61460118557a4971e549ec7457f3eb8f
Summary:
Migrate ScrollView component to use ES6 import
motivation: trying to slowly migrate each files to use es6 import/exports to make this discussion happen
https://github.com/react-native-community/discussions-and-proposals/issues/201#issuecomment-588454552
## Changelog
[General] [Changed] - Use es6 import/export syntax for ScrollView component
Pull Request resolved: https://github.com/facebook/react-native/pull/29184
Test Plan:
Test on RNTester for iOS
currently having trouble starting up RNTester on Android, but will update when I'm able to check on Android
Reviewed By: TheSavior
Differential Revision: D22959782
Pulled By: PeteTheHeat
fbshipit-source-id: c909bddda3b5b2edd26a526eedaa67fadd4c2b51
Summary:
This change makes the behavior of providing a null value to onEndReachedThreshold match the behavior of not providing the prop at all.
## Changelog:
[General] [Changed] - Adjusted VirtualizedList's onEndReachedThreshold default value when null is provided
Reviewed By: olegbl
Differential Revision: D22870445
fbshipit-source-id: 29cbf0550702244007689759846ae0356f06b48d
Summary:
**Note:** This is a carbon copy of D22832730 (3df6f5fb2c). The fixes are stacked on top of this diff, in D22888030.
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D22888032
fbshipit-source-id: 2f1b7ecd39437a3c5ee9c3214419716fde2bbdff
Summary:
Fixes https://github.com/MLH-Fellowship/react-native/issues/34
The PR is part of an effort to update the code comments to match the current documentation on the React Native website. The project is a part of the MLH Fellowship program and involves the automatic generation of the website docs from code comments and flow types as the end result.
To learn more about the project you can visit the project wiki:
- [Project Details](https://github.com/MLH-Fellowship/0.4.x-projects/wiki/React-Native-Flowtype-API-Docs-Generator)
- [RN Docs Standards](https://github.com/MLH-Fellowship/react-native/wiki/RN-Docs-standards)
Link to the documentation(the source of truth):
- [activityindicator.md](https://github.com/MLH-Fellowship/react-native-website/blob/master/docs/activityindicator.md)
## Changes
* Update the title and prop description from docs.
* Remove unnecessary `*` from the code comments.
* Add Snack player example specified in the docs to the code comments as JSDoc.
* Add `type` annotation to parse supported datatype by the prop.
* Add `platform` annotation to specify platforms supported by a prop.
* Add `default` annotation to parse default value of prop.
## Changelog
[Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/29523
Test Plan:
All changes are made to the code comments and thus there is no need for testing.
Reviewed by jevakallio
Reviewed By: cpojer
Differential Revision: D22921419
Pulled By: motiz88
fbshipit-source-id: 3701bf3e3f4e0762529c8a5597263354d5243f07
Summary:
Fixes https://github.com/MLH-Fellowship/react-native/issues/60
The PR is part of an effort to update the code comments to match the current documentation on the React Native website. The project is a part of the MLH Fellowship program and involves the automatic generation of the website docs from code comments and flow types as the end result.
To learn more about the project you can visit the project wiki:
- [Project Details](https://github.com/MLH-Fellowship/0.4.x-projects/wiki/React-Native-Flowtype-API-Docs-Generator)
- [RN Docs Standards](https://github.com/MLH-Fellowship/react-native/wiki/RN-Docs-standards)
Link to the documentation(the source of truth):
- [switch.md](https://github.com/MLH-Fellowship/react-native-website/blob/master/docs/switch.md)
## Changes
* Update the title and prop description from docs.
* Remove unnecessary `*` from the code comments.
* Add Snack player example specified in the docs to the code comments as JSDoc.
* Add `type` annotation to parse supported datatype by the prop.
* Add `platform` annotation to specify platforms supported by a prop.
* Add `default` annotation to parse default value of prop.
## Changelog
[Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/29546
Test Plan:
All changes are made to the code comments and thus there is no need for testing.
Reviewed by jevakallio
Reviewed By: cpojer
Differential Revision: D22921438
Pulled By: motiz88
fbshipit-source-id: eaab1e04252c15d7d3dd18a2b162fa97a4478dd6
Summary:
Fixes https://github.com/MLH-Fellowship/react-native/issues/33
The PR is part of an effort to update the code comments to match the current documentation on the React Native website. The project is a part of MLH fellowship program and involves automatic generation of the website docs from code comments and flow types as the end result.
To learn more about the project you can visit the project wiki:
- [Project details](https://github.com/MLH-Fellowship/0.4.x-projects/wiki/React-Native-Flowtype-API-Docs-Generator)
- [RN Docs Standards](https://github.com/MLH-Fellowship/react-native/wiki/RN-Docs-standards)
Link to the documentation(the source of truth):
- [button.md](https://github.com/MLH-Fellowship/react-native-website/blob/master/docs/button.md)
## Changes
* Update the title and prop description from docs.
* Remove unnecessary `*` from the code comments.
* Add default value to props.
* Specify the default value of a prop in the code comments with `default` annotation.
* For multiple defaults (different devices) use `default {platform android/ios}`.
* Update platforms in props.
* Use comma separated string with `platform` decorator.
* Add Snack player example specified in the docs to the code comments with `example` annotation.
## Changelog
[Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/29155
Test Plan:
All changes are made to the code comments and thus there is no need for testing.
[Reviewed by jevakallio](https://github.com/MLH-Fellowship/react-native/pull/18)
Reviewed By: cpojer
Differential Revision: D22767877
Pulled By: motiz88
fbshipit-source-id: ccad8d58dc2888d44d34fdbb94b3c187542e9f2b
Summary:
There's currently a hidden parameter passed to the LayoutAnimation engine for "failure". It's not been used anywhere, ever, since it's a hidden parameter... and it's probably not called from the native side in non-Fabric. But it's been added to the native side of Fabric for feature-completeness and we might as well expose it, the cost seems minimal.
Changelog: [Internal]
Reviewed By: shergin
Differential Revision: D22889455
fbshipit-source-id: 73322776ed21e58a370500ccfde89285f07a9d50
Summary:
`babel-plugin-codegen` will run the NativeModules codegen on each NativeModule spec, and inline the generated schema into the spec's `TurboModuleRegistry.get(Enforcing)?` call. This diff will forward that schema to `__turboModuleProxy` function (i.e: the TurboModule C++ infra).
**Note:** Both this and D2280384 can't be landed until D22743294 (650c0f64f1) hits production (1-2 weeks).
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D22832730
fbshipit-source-id: aecaf9943f9b01be805ff6b90249a6cbc6abdd20
Summary:
Unfortunately, the new codegen doesn't allow us to import types from other files. Therefore, I've inlined the interface specification of NativeAnimatedModule into NativeAnimatedTurboModule.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D22858790
fbshipit-source-id: 759bb960240afaba6b70c2730c3359b7e8c46c83
Summary:
Changelog: [Internal]
Since D22098586 (476ab7481e) zIndex is only applied to views with position other than static.
Sticky header however needs to have its zIndex applied otherwise it goes below the content.
Reviewed By: mdvacca
Differential Revision: D22843134
fbshipit-source-id: d2e3a21441795b82c44b6d4245ccf89620fd9a8e
Summary:
In Fabric, there are two subtle differences in Animated:
1) On the native side, queued NativeAnimated operations are executed more frequently
2) On the JS side there seems to be a bigger gap between AnimatedNodes being set up, and the final `componentDidMount`/`componentDidUpdate` that results in `_attachNativeEvents` being called.
This results in some visual glitching for certain features like StickyScrollViewHeader and other animations that are frequently rerendered. Rerendering an animated component relies on sync-like behavior
(new animations must be set up in the same frame that old animations are torn down, and the UI must flush any updates in the same frame). This sync-like behavior is trickier to achieve in Fabric, so
we introduce this mechanism, in Fabric only, to queued operations more aggressively on the JS side and only flush them when `componentDidMount`/`componentDidUpdate` have been called on all relevant nodes.
This seems to resolve longstanding issues with animations in Fabric on Android.
There are unrelated issues on iOS that make this difficult to test currently, so I'll keep the new path Android-only for now.
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D22801173
fbshipit-source-id: 3db2235483636c9074df941cfac0a30f3f97545a
Summary:
Discovered when debugging a React Native app in Chrome. The function `performanceNow` was recently changed, so that in Chrome it now refers to `performance.now()` method. However, `now()` cannot be called standalone without a context.
Reproduced by a synthetic example in Chrome:
```
const performanceNow = window.performance.now;
performanceNow();
Uncaught TypeError: Illegal invocation
at <anonymous>:1:1
```
Changelog:
[General] [Fixed] - Fix failure when debugging code in a browser; was caused by `performanceNow()` function.
Reviewed By: cpojer
Differential Revision: D22739176
fbshipit-source-id: f89b8a215b7b4c430ffd72a1d23539c4f1b31d24