Summary: We are working to remove additional types and eventually define everything at the top level as a public exported type of react-native. I was able to update callsites by just using ViewStyleProp in places that were expecting a prop of just one of these. It is a little bit weaker, but much simpler. If a callsite wants to only take margin, it should just take a margin prop instead of a LayoutStyle prop.
Reviewed By: rickhanlonii
Differential Revision: D13599460
fbshipit-source-id: 12c01bc58baa7f6acf33e0b8aab05dabb79c646b
Summary:
Prior to this change, when you passed text to `TextInput` via the `value` or `defaultValue` props, React Native didn't apply any of the styles in `buildSpannedFromShadowNode` to the text. This is because `spannedFromShadowNode` appends `value` after calling `buildSpannedFromShadowNode`. Many styles worked because their logic is included in both `buildSpannedFromShadowNode` and `ReactTextInputManager`. However, some only appear in `buildSpannedFromShadowNode` such as `textDecorationLine` (it would be good to understand why we need to duplicate styling logic in `buildSpannedFromShadowNode` & `ReactTextInputManager` and to know whether `ReactTextInputManager` should be handling `textDecorationLine`).
Also, this commit improves consistency between iOS and Android if you specify both `value` and children on a `TextInput`. Prior to this, iOS concatenated the strings such that the `value` prop came before the children whereas Android put the children before the `value` prop. Now Android matches iOS's behavior and puts the `value` prop before the children.
These appear to be regressions. The `value` prop used to be appended before calling `buildSpannedFromShadowNode` (this behavior appears to have been changed by accident in 80027ce6db (diff-4f5947f2fe0381c4a6373a30e596b8c3)).
The fix is to append the `value` prop before calling `buildSpannedFromShadowNode`. Additionally, we have to expose a new `start` parameter on `buildSpannedFromShadowNode` so that we can tell it to include the text from the `value` prop in the range that it styles. Without this, the start of the styled text would be immediately after `value` because `value` is appended before calling `buildSpannedFromShadowNode`
Pull Request resolved: https://github.com/facebook/react-native/pull/22461
Reviewed By: mdvacca
Differential Revision: D13282065
Pulled By: shergin
fbshipit-source-id: 4c99094741441cf54cdec0075bfd08ff7d889e66
Summary:
@public
Wraps enum definition in a single macro.
Down the line, this will allow us to add more functionality:
- Replace manual counts with `yoga::enums::count<YG...>()`
- `yoga::enums::max<YG...>()`
- A bitfield implementation with known memory layout using `max<>()`
Reviewed By: SidharthGuglani
Differential Revision: D13597259
fbshipit-source-id: 543a11a53090bedf1474d00328565ed57d059e23
Summary:
The original commit was backed out due to a build failure, which seems to be due to compiler flag misconfiguration. That has been fixed.
Original commit: f2fccbb327
Reviewed By: mdvacca
Differential Revision: D13593075
fbshipit-source-id: f3a65e8bd9830f6ac2ea829020500b4632ee2149
Summary: Replaced all deprecated ALAssets* references to roughly equivalent PHPhoto* references in RCTCameraRoll library. There are still some minor inconsistencies between iOS/Android and documentation that existed prior to this diff that need to be resolved after this.
Reviewed By: fkgozali
Differential Revision: D13593314
fbshipit-source-id: 6d3dc43383e3ad6e3dbe73d4ceceac1ba9261d9d
Summary: This diff ensures that the 'measure' method in TextLayoutManager is memoized using a static variable.
Reviewed By: fkgozali
Differential Revision: D13585508
fbshipit-source-id: 9275a4d193b8abb0c3aaffd5a5535234717475e1
Summary:
Moved the JS wrapper function to github. To access a TurboModule from JS:
```
export interface Spec extends TurboModule {
+func1: () => number,
}
const module = TurboModuleRegistry.get<Spec>('SampleTurboModule');
```
This assumes:
* the binding on the native side has been installed properly, i.e. `global.__turboModuleProxy` needs to be installed properly.
* the module `SampleTurboModule` is registered properly in native.
More instructions will be provided later.
Reviewed By: yungsters
Differential Revision: D13584561
fbshipit-source-id: 50d29d88787f8d9caa7a3ee0d54d378db866515c
Summary:
This is the iOS binding for TurboModule.
To install the TurboModule binding:
* Provide `RCTCxxBridgeDelegate`
* Provide `RCTTurboModuleManagerDelegate`
Somewhere in `RCTCxxBridgeDelegate` impl:
```
RCTTurboModuleManager *manager = [[RCTTurboModuleManager alloc] initWithRuntime:&runtime bridge:bridge delegate:self];
[manager installJSBinding];
```
Doing so will install `global.__turboModuleProxy()` in JS space.
Note:
* The full instructions will be provided once all pieces are moved to OSS.
* Sample modules and binding setup will be provided later.
Reviewed By: RSNara
Differential Revision: D13583442
fbshipit-source-id: bb1cabd973e8a9ec59da6b145826e9ea234a96b3
Summary:
There's been a bug on iOS and iPad that the position of an action sheet using UIActionController isn't updated if the position of its anchor view changes due to rotating the device. A common scenario would be, presenting an action sheet from a right bar button item. Rotating the device will most likely change the bar button's X coordinate. The action sheets arrow would still point to the old position due to how it has been implemented so far.
I used also reduced some code duplication between `-showActionSheetWithOptions` and `-showShareActionSheetWithOptions:` while at it.
Changelog:
----------
[iOS] [Fixed] - Action Sheet position after rotation on tablet
Pull Request resolved: https://github.com/facebook/react-native/pull/22738
Differential Revision: D13582810
Pulled By: PeteTheHeat
fbshipit-source-id: a93065284b02efc41ae7378465521330a828a126
Summary: This diff switches `Text.style` from `DangerouslyImpreciseStyle` to `TextStyleProps` and fixes/ignores the related flow issues
Reviewed By: TheSavior
Differential Revision: D13568053
fbshipit-source-id: b4b6f8c22323faf9592ef13697043bb181c77423
Summary:
This diff moves the dispatching of views to the React Choreographer, this help to sort the mount of views following the order specified in the ReactChoreographer class.
This also enables synchronous and correct order for mounting of views that are dispatched in the UI Thread.
Reviewed By: sahrens
Differential Revision: D13444487
fbshipit-source-id: d8a43f473b07c9ccf7ea3bc9ab90545ec3c9ecee
Summary: It was pointed out to me in https://github.com/facebook/react-native/pull/22508 by raphael-liu that the error message refers to the wrong tag. I didn't merge the PR because I don't have good insight into the effects it could cause, but we should at least fix the error message.
Reviewed By: TheSavior
Differential Revision: D13564266
fbshipit-source-id: fa76f0888364df329d052dbcc2050f906d39dcef
Summary:
Fixes#21086.
Fixes#6117.
This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.
This PR mainly changes:
* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: https://github.com/facebook/react-native/pull/22439
Differential Revision: D13564247
Pulled By: cpojer
fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
Summary:
This PR adds flow types for the RNTester examples, and updates all of the RNTester examples to match the flow type consistently.
Previously, there was a mix of static class definitions and whether or not pages exported examples or a component. Now we will always export the same way, enforced by flow types
Note: I also fixed most of the $FlowFixMe in changed components
Pull Request resolved: https://github.com/facebook/react-native/pull/22829
Reviewed By: cpojer
Differential Revision: D13563191
Pulled By: rickhanlonii
fbshipit-source-id: b697e3346a863d1b130881592b0522a96c202b63
Summary:
This PR adds filtering for e2e test examples using the new examples filter introduced in https://github.com/facebook/react-native/pull/22777
To do that we:
- Add a `testID` to `RNTesterExampleFilter` to select an example
- Refactor a few examples to export multiple examples for filtering
- Update all tests to filter by example title
Pull Request resolved: https://github.com/facebook/react-native/pull/22828
Reviewed By: TheSavior
Differential Revision: D13562664
Pulled By: rickhanlonii
fbshipit-source-id: efb0ca8050c1ca5c10d96bd77d35dd1143c3a3b3
Summary: Since we started relying on NativeModules' getConstants() method to access constants, we need to update our jest mocks of these NativeModules, so that the tests still pass. I do that in this diff.
Reviewed By: fkgozali
Differential Revision: D13561376
fbshipit-source-id: eaef3de82d842fd97d04be741d55bdded73c6a11
Summary:
This PR adds filtering functionality to individual example screens of RNTester. This is useful for Detox testing of RNTester, since Detox requires elements to be visible on the screen before they can be interacted with. Instead of needing to scroll an arbitrary amount, the test can enter the name of the example to be tested, just as is done on the main screen. This will lead to simpler and more reliable E2E tests for long example screens. This PR doesn't add any automated tests using the filter; those will be added in a separate PR.
This is implemented by extracting the existing filtering functionality out of `RNTesterExampleList` into a shared `RNTesterExampleFilter` component that can be used both within `RNTesterExampleList` (the main screen) and `RNTesterExampleContainer` (the example screen).


Changelog:
----------
[General] [Added] - Added filtering to RNTester example screens
Pull Request resolved: https://github.com/facebook/react-native/pull/22777
Reviewed By: TheSavior
Differential Revision: D13561744
Pulled By: rickhanlonii
fbshipit-source-id: cb120626a8e2b8440f88b871557c0b92fbef5edc
Summary: Add a catch statement for NPE around ViewGroup's dispatchDraw and log it
Reviewed By: mdvacca
Differential Revision: D13554441
fbshipit-source-id: a94d3db71678e17ef6bcda46689a069b85e460c5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/22231
- Use clang instead of the deprecated gcc
- Use libc++ instead of the deprecated gnustl
- Updated gradle and android plugin version
- Fixed missing arch in local-cli template
- `clean` task should now always succeed
- `clean` task deletes build artifacts
- No need to specify buildToolsVersion. It's derived.
- Elvis operator for more readable code
Pull Request resolved: https://github.com/facebook/react-native/pull/22263
Reviewed By: hramos
Differential Revision: D13004499
Pulled By: DanielZlotin
fbshipit-source-id: da54bb744cedb4c6f3bda590f8c25d0ad64086ef
Summary:
This change enables defining the macro at a more global and central location. And thereby allowing us to building this file using MSVC.
Pull Request resolved: https://github.com/facebook/react-native/pull/22561
Reviewed By: fkgozali
Differential Revision: D13529762
Pulled By: RSNara
fbshipit-source-id: c78abb26f47aba25d50305c5bc0b23b6568f1243
Summary:
This diff fixes a NPE that can occur when we force the dispatching of events when the EventDispatcher is not initized.
The fix consists on avoid posting the frame callback, if the internals of EventDispatcher are not initialized yet (same behavior used by the dispatchEvent method)
Reviewed By: fkgozali
Differential Revision: D13549147
fbshipit-source-id: ef3baeb536e8772fbd83024352a37af01c21d589
Summary:
This is only the core C++ part of TurboModule - moving to github to make integration with existing NativeModules system slightly easier. Other bindings for iOS/Android are not yet ready to move.
Notes:
* TurboModules is not ready to use at the moment.
* Build configuration is not yet provided (cocoapods/.xcodeproj/gradle), just like Fabric.
* No effort was done to make this lib C++17 strictly compliant yet (there will be in the future).
Reviewed By: RSNara
Differential Revision: D13551211
fbshipit-source-id: cd3b458e6746ee9218451962ca65b1ad641a32db
Summary: Catch `IllegalArgumentException: ReactViewPager.onTouchEvent` and ignore it (but log something) to work around this known bug in the Android SDK per https://github.com/chrisbanes/PhotoView/issues/31#issuecomment-19803926. Note that `onInterceptTouchEvent()` is already doing the same thing.
Reviewed By: yungsters
Differential Revision: D13550425
fbshipit-source-id: 9fa3a7a0ca0cd95aafa3bcae6a59e0d1e690b564
Summary: Adds a workaround to `ReactTextView` for a crash that happens in `getOffsetForHorizontal`: https://issuetracker.google.com/issues/113348914
Reviewed By: mdvacca
Differential Revision: D13548917
fbshipit-source-id: 1c346283cd036c88d60a4b10890ade46c7e80eca
Summary:
This diff fixes a race condition that was detected on "Marketplace You" production test for Android.
The race condition happens when the method ShadowTree::complete is executed concurrently from two threads (in this case this is called from Scheduller::constraintSurfaceLayout and Scheduler::uiManagerDidFinishTransaction), based on the order of execution this bug makes MountViewItems to be dispatched to the UI in the wrong order.
The root cause of the bug is in the method:
```
bool ShadowTree::complete(
const SharedRootShadowNode &oldRootShadowNode,
const UnsharedRootShadowNode &newRootShadowNode) const {
newRootShadowNode->layout();
newRootShadowNode->sealRecursive();
auto mutations =
calculateShadowViewMutations(*oldRootShadowNode, *newRootShadowNode);
if (!commit(oldRootShadowNode, newRootShadowNode, mutations)) {
return false;
}
emitLayoutEvents(mutations);
if (delegate_) {
delegate_->shadowTreeDidCommit(*this, mutations);
}
return true;
}
```
Notes:
- the commit method is guarded by the commitMutex_
- the shadowTreeDidCommit() method dispatches mutations instructions to the platform side.
- If there are two threads running concurrently, there is no guarantee that the shadowTreeDidCommit() is going to be called in the correct order.
The solution is to include the execution to shadowTreeDidCommit() in the same commitMutex_
Possible solutions:
1 - move the commitMutex_ out of the commit method (to the completeMethod)
2 - synchronize the call to complete method() - this is the implemented solution.
I chose this solution to make it consistent with the way Scheduler::constraintSurfaceLayout is implemented (https://fburl.com/8l49no5x)
This mechanism is very likely to change in the refactor of threading mechanism that Valentin Shergin is going to be working on January.
I would like to land this, so we can fix this bug and run another experiment in production as soon as possible.
Reviewed By: sahrens
Differential Revision: D13535587
fbshipit-source-id: bedd4d85f5569ab3733c302d1328aa48017bcaad
Summary: In some rare race condition (usually involving network request handling vs bridge shutting down), there may be bad access to an RCTModuleData that may have been de-allocated. To prevent crashes, let's guard the access and return nil appropriately.
Reviewed By: yungsters
Differential Revision: D13548755
fbshipit-source-id: b97326524cd9ca70a13d15098a1eaadfc7f1a6a8
Summary: In D13307775, ScrollView was changed into a `React.Component` subclass. The solution needed a few touchups, so I added them in this diff.
Reviewed By: TheSavior
Differential Revision: D13404191
fbshipit-source-id: cba2ddab1fb92a2cbb91b59ac9ae5b5d51d91eb8
Summary:
As a part of https://github.com/facebook/react-native/pull/22301 it turned out that we need to first convert `ScrollView` to class component. As a first step to do so, here's removal of using `mixins` API, in favor of populating `_scrollResponder` field with `ScrollResponder.Mixin` (still used) methods.
Pull Request resolved: https://github.com/facebook/react-native/pull/22374
Reviewed By: TheSavior
Differential Revision: D13307775
Pulled By: RSNara
fbshipit-source-id: 16be1df8a0bf9ccc5cc32f3a017a1279f99268ed
Summary:
This removes the use of the legacy context API in `TextInput`.
Nothing in OSS appears to make use of the `focusEmitter`.
Pull Request resolved: https://github.com/facebook/react-native/pull/22220
Reviewed By: TheSavior
Differential Revision: D13408886
Pulled By: RSNara
fbshipit-source-id: 9ae597507ccc26a9bc944a44c1f51b91e73cd637
Summary: Replaced all deprecated ALAssets* references to roughly equivalent PHPhoto* references in RCTCameraRoll library. There are still some minor inconsistencies between iOS/Android and documentation that existed prior to this diff that need to be resolved after this.
Reviewed By: fkgozali, PeteTheHeat
Differential Revision: D13513777
fbshipit-source-id: 3f0c4ae259823fae78eba875a6c259733715ab56
Summary:
shergin mentioned that he'd like to move away from RTTI a bit and use explicit key strings for context container instances rather than relying on the `typeid`, so this does this.
We also fatal with a useful error message if we get a collision, rather than failing silently.
Reviewed By: shergin
Differential Revision: D13384308
fbshipit-source-id: 0b06d7555b082be89e8f130c23e94be99749a7a3
Summary:
`RCTSurfaceHostingProxyRootView` surfaces are still automatically started right after the initialization to match `RCTRootView` interface, but `RCTSurfaceHostingView` must be started explicitly now. Also fixed some internal stuff so start and register are clear and distinct.
Background / initial motivation:
One tricky bit - we render the template as part of init`ing the rootView, so we don't know what the surfaceId will be before hand to register the UITemplate. Two possible solutions:
1) Require start be called explicitly after initializing the rootView, and setup the context in between.
2) Do something like "setUITemplateConfigForNextSurface" before creating the rootView, and have some hook when the surfaceId is assigned that associates the surfaceId with that "next" UITemplate stuff before.
(1) seems a lot cleaner, but it requires ever user of rootView to explicitly call start on it - how do you feel about that? Seems like we could also use that start call to decide if the initial render should be synchronous or not? start vs. startSync?
Reviewed By: mdvacca
Differential Revision: D13372914
fbshipit-source-id: 6db297870610e6c231f8a78c0dd74d584cb64910
Summary: We need a way for different apps to inject dependencies or additional functionality into Fabric - ReactNativeConfig might be a special case, but I think this could clean up it's integration nicely, and I'm using this for a uitemplate cache system so we can use CompactDisk or other storage systems for caching depending on the app.
Reviewed By: mdvacca
Differential Revision: D13407287
fbshipit-source-id: 45481908434e6235850aa4d2d6b2bfb936a23be7
Summary:
Hi Team!
This PR fixes#22741
Thanks for labeling as Good First Issue!
Changelog:
----------
[General] [Fixed] - fix deprecation warning of testResultsProcessor flag in test-ci
Pull Request resolved: https://github.com/facebook/react-native/pull/22749
Differential Revision: D13542419
Pulled By: hramos
fbshipit-source-id: 84f33329a6b9431ed1db843a99e7db7dbeda5361
Summary:
The following tests are disabled in this PR:
- testTimersTest is failing due to undefined this.setTimeout, probably introduced back in 61346d3. Tracking a fix in https://github.com/facebook/react-native/issues/22695
- testTheTester_ExpectError is failing as RCTTestRunner is not properly passing through the error. Tracking a fix in https://github.com/facebook/react-native/issues/22697
I've added a comment regarding testWebSocketTest and how to ensure it passes locally.
This PR also fixes all remaining snapshot tests, which were failing due to the use of iPhone XS as a iOS Simulator on Circle CI. We are using iPhone 6s for SST internally, and this allows us to be consistent.
Pull Request resolved: https://github.com/facebook/react-native/pull/22720
Differential Revision: D13532788
Pulled By: hramos
fbshipit-source-id: 75681236032839bf88180611ee68826b53cc96eb
Summary:
This is very much a work in progress. Moving it into the open source repo to be able to hook it up to generate some Fabric files.
Will continue to iterate on it in the open.
Reviewed By: hramos, mdvacca
Differential Revision: D13500969
fbshipit-source-id: 79082447dc52b5834f24eb72bc6e07200b324238