Summary:
Related to #22100
Enhance ViewPropTypes flow types.
- I had some troubles with a TODO left for `onResponderGrant` hence the return type.
- I wasn't able to properly type `nativeBackgroundAndroid` and `nativeForegroundAndroid` at the moment.
Pull Request resolved: https://github.com/facebook/react-native/pull/22504
Reviewed By: cpojer
Differential Revision: D13334024
Pulled By: TheSavior
fbshipit-source-id: cada236e0d716ae78cb663172e5315cf11c6406a
Summary:
`instance.hasOwnProperty` has potential danger because of some object could be eliminate own prototype chain. Update code be more reliable.
This PR is solution of #22308 issue. (Fixes#22308)
Pull Request resolved: https://github.com/facebook/react-native/pull/22348
Differential Revision: D13334882
Pulled By: cpojer
fbshipit-source-id: 9b9310a972e933af1962666d7b0c683ff43cc5b2
Summary:
Related to #22100
Enhance TouchableWithoutFeedback with press and target event types.
There are still work to do to update `UNSAFE_componentWillReceiveProps` and `touchableGetHitSlop` to make Flow not complain about `DeprecatedEdgeInsetsPropType` inexact type.
Pull Request resolved: https://github.com/facebook/react-native/pull/22479
Reviewed By: RSNara
Differential Revision: D13310764
Pulled By: TheSavior
fbshipit-source-id: 9002e542378491fb800c8e81c63f4fbe125b563c
Summary:
iOS-specific.
For languages with complex input (such as Japanese or Chinese), a user has to type multiple characters that are then merged into a single one.
If `-[UITextView setAttributedString:]` is used while the user is still typing, it resets the input and characters are not being treated as typed together.
This PR avoids calling this method if possible, replacing it by just copying the attributes if the string has not been changed. That preserves the state and user can continue to type Korean or Chinese characters.
Fixes#19339
<!--
Required: Write your motivation here.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->
<!--
Required: Write your test plan here. If you changed any code, please provide us with
clear instructions on how you verified your changes work. Bonus points for screenshots and videos!
-->
Essentially, the steps to reproduce are described in [the issue](https://github.com/facebook/react-native/issues/19339):
1. Type some Korean characters in TextInput, such as "하늘" (buttons `ㅎ`,`ㅏ`,`ㄴ`,`ㅡ`,`ㄹ`).
2. Then move the cursor to the beginning of the text, type "파란" (buttons `ㅍ`,`ㅏ`,`ㄹ`,`ㅏ`,`ㄴ`) this time.
**Behaviour before this fix (broken)**
Actual text: `ㅍㅏㄹㅏㄴ하늘`.
Expected text: `파란하늘`.
Characters aren't combined properly.

**Behaviour after this fix (correct)**
Actual text: `파란하늘`.
Expected text: `파란하늘`.
Characters are combined, the same behaviour is in vanilla iOS `UITextView`.

<!--
Does this PR require a documentation change?
Create a PR at https://github.com/facebook/react-native-website and add a link to it here.
-->
<!--
Required.
Help reviewers and the release process by writing your own release notes. See below for an example.
-->
[IOS] [BUGFIX] [TextView] - Fix Korean/Chinese/Japanese input for multiline TextView on iOS.
<!--
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [ {Component} ]
[ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Pull Request resolved: https://github.com/facebook/react-native/pull/19809
Differential Revision: D13326614
Pulled By: shergin
fbshipit-source-id: 6a5cab3f7290f0f623a6f4c29353a573eb321b0b
Summary:
I think a common pattern is to use async functions with the onRefresh prop to reload data. I made the type `mixed` since we don't care about what the function returns. Could also be `void | Promise<void>` I haven't really seen a pattern for those in the codebase.
Pull Request resolved: https://github.com/facebook/react-native/pull/22376
Differential Revision: D13310372
Pulled By: TheSavior
fbshipit-source-id: 445f28cf2c37f9c937e72d76716002deaf9d9c94
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.
Reviewed By: yungsters
Differential Revision: D13195941
fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
Summary:
This was in the wrong section
[Internal]
Reviewed By: yungsters
Differential Revision: D13285234
fbshipit-source-id: 1c3b3825a0f99028efe1f1f002d5519ad6ab4494
Summary:
Currently, if you load an animated gif using the standard `Image` component, it will not correctly respect the loop count property found in the Netscape App Extension block of the file. The issues are as follows:
1) If the App Extension isn't present, the animated gif loops indefinitely when it should not loop at all.
2) If the App Extension is present, the animated gif loops one less time than it should.
The other issue is that once the looping completes, the image doesn't pause at the last frame but instead, loops back to the beginning of the animation e.g. frame 1.
The fix does a few things:
1) If there is _no_ App Extension present, the image doesn't loop at all
2) If there _is_ an App Extension present, it loops the correct amount of times. For instance, if the loop count is 1, it means the gif should loop _once_ after it finishes playing, for a total of _two_ total loops.
3) Once the number of loops completes (assuming loop count isn't set to 0 which means infinite), the animation pauses on the last frame.
Pull Request resolved: https://github.com/facebook/react-native/pull/21999
Differential Revision: D13287005
Pulled By: hramos
fbshipit-source-id: f7210ad40e0e76c9ec454953b8a067569d3feaaa
Summary: This change attempts to fix a crash within RCTImageCache's new dateWithHeaderString method. This is a speculative fix as there aren't any concrete repro steps.
Reviewed By: hramos
Differential Revision: D13278666
fbshipit-source-id: cdb69b1296c946d89e14c074329280994d87ddcd
Summary:
Instead of assigning all the constants exported by a NativeModule to the native module JavaScript object itself, we want to instead export a `getConstants()` method that can be used to access native module constants. This change simplifies the API of native modules. Eventually, we'll remove the ability to access constants as native module object properties alltogether, but that's comes later.
**Note**: I didn't need to make any cpp changes because `JSIExecutor::NativeModuleProxy::get` calls `JSINativeModules::getModule` (here: https://goo.gl/QwPDWF), which eventually calls `JSINativeModules::createModule`, which uses `global.__fbGenNativeModule` (here: https://goo.gl/pSxMgE), which is just an alias to `genModule` in `NativeModules` (here: https://goo.gl/u2wjCs).
Reviewed By: fkgozali
Differential Revision: D13207152
fbshipit-source-id: 375aab1346232819187a5d5b272b33c55992346a
Summary: On Android, `Switch` does not currently read its role as a "button". This fixes that and makes it consistent with iOS.
Reviewed By: sahrens
Differential Revision: D13136253
fbshipit-source-id: 0de5d54772d204168138cb2af7815cc458f72682
Summary:
Modified the ESLint configuration to only enable the Jest environment for files we consider now tests, which are files with the `-test.js` suffix under `__tests__`. Also enabled some globals for test helpers (any file under `__tests__`).
This will allow us to catch misspelled tests, while allowing test helpers to use most Jest APIs.
Also disabled the Jasmine environment so people stop using Jasmine APIs and we can rollout Circus soon.
Reviewed By: aaronabramov
Differential Revision: D13199591
fbshipit-source-id: 12a32cf5835630b9987452b0c33d3f8085001689
Summary:
Similar to #21950, this adds displayName to `ActivityIndicator`, so it displays the correct component name in snapshots instead of `Component`.
Fixes#21937 (a little bit more than it was already fixed).
Pull Request resolved: https://github.com/facebook/react-native/pull/22417
Differential Revision: D13205376
Pulled By: TheSavior
fbshipit-source-id: 21e71d4980d159a1f33d32d83346b48257ec21d4
Summary:
Renamed test files to match `-test.js`, so people can add test helpers without blacklisting.
Codemod code: P60365841
Script executed:
```
cd xplat/js
./scripts/node/node rename-script.js > result.txt
```
Reviewed By: mjesun
Differential Revision: D13185673
fbshipit-source-id: 87451635aa538c2c1d1886e75574d0e5c889596e
Summary: As suggested by yungsters in D13138187
Reviewed By: mjesun
Differential Revision: D13192765
fbshipit-source-id: 8ab3dc74b3a9aaebf043bc3b5ed4f2590f480d10
Summary: There is only a single use of this function across RN, and one more use in a test file. I inlined this function in both places to reduce the dependency on fbjs.
Reviewed By: yungsters
Differential Revision: D13138137
fbshipit-source-id: 32660c965a975d17e236bdd13ff0b2a8d64751ee
Summary: There are no DOM Nodes in React Native so our Map polyfill does not need to consider that use case. I deleted the references to `isNode` and `IE. In case this is important for react-native-web, I suggest to shim the Map polyfill with an IE compatible one outside of react-native.
Reviewed By: yungsters
Differential Revision: D13138030
fbshipit-source-id: 661511ea03b4477bd55d0fdf5e485178fe59d96b
Summary: This module simply forwards to the `promise` module. I inlined the code to remove the dependency.
Reviewed By: yungsters
Differential Revision: D13137980
fbshipit-source-id: e3d6208068911711fc5f5378f2d5bb6ac38f2eb2
Summary:
Related to #22100
Enhance Flow types for TouchableOpacity specifying underlay functions and TvParallaxPropertiesType.
I had to export and enhance TvParallaxPropertiesType from TVViewPropTypes file. This does not break this other PR also using this exported type. #22146
There is still some work to do in order to turn flow to strict mode.
- All flow tests succeed.
[GENERAL] [ENHANCEMENT] [TouchableHighlight.js] - Flow types
[GENERAL] [ENHANCEMENT] [TVViewPropTypes.js] - Export and enhance type
Pull Request resolved: https://github.com/facebook/react-native/pull/22173
Differential Revision: D13033441
Pulled By: RSNara
fbshipit-source-id: 26a38970923dc7e6c02c03da5d08483a3f1fbd36
Summary:
Some of the flow types were incomplete. So, I referenced the code in `~/fbsource/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/views/textinput/` and in `~/fbsource/xplat/js/react-native-github/Libraries/Text/TextInput/` to make the flow types more specific.
I also fixed internal breakages. To avoid having to sprinkle `$FlowFixMe`s everywhere, I had to refactor some types, and some code.
Reviewed By: TheSavior
Differential Revision: D13121871
fbshipit-source-id: 9796aafc861544baf52d7ade823ab1be2d3f12d1
Summary:
Related to #22100
Enhance TextInput with callback event types.
This is a first draft and I will need more help on this one. Flow checks are successful now but I am not sure types are accurate though.
Moreover I find my separation approach kind of dirty for callback event types.
- All flow tests succeed.
[GENERAL] [ENHANCEMENT] [TextInput.js] - Flow types
[GENERAL] [ENHANCEMENT] [TextInputExample.android.js] - Fixing Flow types
[GENERAL] [ENHANCEMENT] [TextInputExample.ios.js] - Fixing Flow types
[GENERAL] [ENHANCEMENT] [XHRExampleFetch.js] - Fixing Flow types
Pull Request resolved: https://github.com/facebook/react-native/pull/22250
Reviewed By: TheSavior
Differential Revision: D13104820
Pulled By: RSNara
fbshipit-source-id: 3fbb98d0ec2b62be676f71ae1053933d9c78485e
Summary:
Related to #22100
Turn on Flow strict mode for TextProps.
I used ResponseHandlers type definition defined in Text.js.
I wanted to move ResponseHandlers type to TextProps and reuse it inside the file.
I know I could use $Shape<> to maybe keys but how do I elegantly maybe every values ?
Unless having a straightforward solution, I found it clearer to copy paste these types.
- All flow tests succeed.
[GENERAL] [ENHANCEMENT] [TextProps.js] - Flow strict mode
Pull Request resolved: https://github.com/facebook/react-native/pull/22122
Reviewed By: TheSavior
Differential Revision: D13055759
Pulled By: RSNara
fbshipit-source-id: 230b43c7c94d7f82f5727ad11541b0cb98bc5e3a
Summary:
Related to #22100
Enhance TouchableBounce with press event types, callback and hitslop types.
There is still some work to do in order to turn flow to strict mode. (requireNativeComponent and render function)
- All flow tests succeed.
[GENERAL] [ENHANCEMENT] [TouchableBounce.js] - Flow types
Pull Request resolved: https://github.com/facebook/react-native/pull/22197
Reviewed By: TheSavior
Differential Revision: D13032452
Pulled By: RSNara
fbshipit-source-id: b21140722ce924698aa15323602e2e3fc663dbb6
Summary:
If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text.
This commit fixes this by marking the inline view as hidden if it appears after the truncation point.
This appears to be a regression. React Native used to have logic similar to what this commit is adding: 1e2a924ba6/Libraries/Text/RCTShadowText.m (L186-L192)
**Before fix**
Inline view (blue square) is visible even though it appears after the truncation point:

The full text being rendered was:
```
<Text numberOfLines={1}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
<View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
</Text>
```
**After fix**
Inline view is properly truncated:

**Test Plan**
Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point.
**Release Notes**
[IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated
Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/react-native/pull/21456
Differential Revision: D10182991
Pulled By: shergin
fbshipit-source-id: a5bddddb1bb8672b61d4feaa04013a92c8224155
Summary:
I noticed that the _onBlur method was not exactly similar to the _onFocus one in the TextInput component.
After digging, I found that the blurTextInput method in the TextInputState.js file was call twice in a raw instead of once when the textinput component should blur.
By removing this line, I fix this unecessary multiple call.
Pull Request resolved: https://github.com/facebook/react-native/pull/22156
Reviewed By: TheSavior
Differential Revision: D13105396
Pulled By: RSNara
fbshipit-source-id: 8e83461d8b288d8ee4047bc4a33c4480e193c349
Summary:
This pull requests converts `DrawerLayoutAndroid` from a `createReactClass`-based component to an ES6 class component, removing its use of `NativeMethodsMixin` and `prop-types` in the process.
Unfortunately this couldn't be moved over to a full `forwardRef` to the native component, because it has the methods `openDrawer` and `closeDrawer` as part of its API, and they can't be called directly on the native component. A `createRef`-based ref to the native component can be accessed from the `nativeRef` property of a `DrawerLayoutAndroid` instance if a native ref is needed.
The Flow types for callbacks have also been filled out.
Pull Request resolved: https://github.com/facebook/react-native/pull/21980
Reviewed By: TheSavior
Differential Revision: D12901951
Pulled By: RSNara
fbshipit-source-id: d35fa5f11b1059f49b466b52abeec902db1d22f7
Summary:
Back it out again. This time really not sure why this is breaking, but it seems to be production only. The error seems to be "RCTSinglelineTextInputView" was not found in the UIManager" but the relavent logic is not changed in this diff, just moved around, so unclear why it would trigger a failure.
Reverting to be safe. When we re-apply the diff, we'll need to test a full OTA to prod to verify the fix.
Reviewed By: blairvanderhoof
Differential Revision: D13108463
fbshipit-source-id: 5f877a0c1a08dc114ce45921d6d92bf619575977
Summary: Adds a `bounce` method that just bounces the element without invoking any callbacks.
Differential Revision: D13085800
fbshipit-source-id: 310b273b260c924fbde32bfad1de7226d068bd57
Summary: D10515754 reapplied by backing out D12989604 and then fixed by manually forwarding the instance methods to the host function instead of using `forwardRef`. This also removes the need for the $flowFixMe.
Reviewed By: TheSavior
Differential Revision: D13048482
fbshipit-source-id: ff2447aff123e0960eddaef645f7dc976a426e14
Summary: Adds a basic test that would have prevented S168585. We should expand coverage of this and other components as well.
Reviewed By: TheSavior
Differential Revision: D13038064
fbshipit-source-id: 14cf4742efd53d7bca2a3f8d1c5c34ebc6227674
Summary: Changed front-facing camera so that it shows consistent image during capture and preview
Reviewed By: mmmulani
Differential Revision: D13012715
fbshipit-source-id: 043cd9178fc49ef9e8e628a866dd8e52434f7306
Summary:
Fixes two problems I uncovered with React Native:
1. `FBCore/Prelude` points to `React.unstable_AsyncMode` which is not defined. (This type was renamed to `React.unstable_ConcurrentMode` in React v16.6.0. **As a result** people in the "react_native:async_rendering" GK will no longer get runtime errors on app start.
2. Updates `react-devtools` and (more importantly) `react-devtools-core` to 3.4.2 to handle the React-internal tag/type refactoring that happened prior to the release of 16.6.0. **As a result** DevTools will no longer cause a runtime error when connected to React Native.
For the second change, I ran `js1 upgrade react-devtools -v ^3.4.2`
Reviewed By: sebmarkbage
Differential Revision: D13030590
fbshipit-source-id: 603f7f6259f282839039820bcdba4310064a7965