From 5c21d1e2d8bb114397d32caf9235eb2cce00d388 Mon Sep 17 00:00:00 2001 From: Chi-AnTai Date: Tue, 15 Jan 2019 15:24:58 +0800 Subject: [PATCH 1/4] create standalone js file for RCTPicker --- Libraries/Components/Picker/PickerIOS.ios.js | 22 +-------- .../Picker/RCTPickerNativeComponent.js | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 Libraries/Components/Picker/RCTPickerNativeComponent.js diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 787126356a4974..224ab32eee78d2 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -18,7 +18,7 @@ const ReactNative = require('ReactNative'); const StyleSheet = require('StyleSheet'); const View = require('View'); const processColor = require('processColor'); -const requireNativeComponent = require('requireNativeComponent'); +const RCTPickerNativeComponent = require('RCTPickerNativeComponent'); import type {SyntheticEvent} from 'CoreEventTypes'; import type {ColorValue} from 'StyleSheetTypes'; @@ -38,24 +38,6 @@ type RCTPickerIOSItemType = $ReadOnly<{| textColor: ?number, |}>; -type RCTPickerIOSType = Class< - ReactNative.NativeComponent< - $ReadOnly<{| - items: $ReadOnlyArray, - onChange: (event: PickerIOSChangeEvent) => void, - onResponderTerminationRequest: () => boolean, - onStartShouldSetResponder: () => boolean, - selectedIndex: number, - style?: ?TextStyleProp, - testID?: ?string, - |}>, - >, ->; - -const RCTPickerIOS: RCTPickerIOSType = (requireNativeComponent( - 'RCTPicker', -): any); - type Label = Stringish | number; type Props = $ReadOnly<{| @@ -111,7 +93,7 @@ class PickerIOS extends React.Component { render() { return ( - { this._picker = picker; }} diff --git a/Libraries/Components/Picker/RCTPickerNativeComponent.js b/Libraries/Components/Picker/RCTPickerNativeComponent.js new file mode 100644 index 00000000000000..3c237f76a49042 --- /dev/null +++ b/Libraries/Components/Picker/RCTPickerNativeComponent.js @@ -0,0 +1,48 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +const requireNativeComponent = require('requireNativeComponent'); + +import type {SyntheticEvent} from 'CoreEventTypes'; +import type {TextStyleProp} from 'StyleSheet'; + +type PickerIOSChangeEvent = SyntheticEvent< + $ReadOnly<{| + newValue: number | string, + newIndex: number, + |}>, +>; + +type RCTPickerIOSItemType = $ReadOnly<{| + label: ?Label, + value: ?(number | string), + textColor: ?number, +|}>; + +type Label = Stringish | number; + +type RCTPickerIOSType = Class< + ReactNative.NativeComponent< + $ReadOnly<{| + items: $ReadOnlyArray, + onChange: (event: PickerIOSChangeEvent) => void, + onResponderTerminationRequest: () => boolean, + onStartShouldSetResponder: () => boolean, + selectedIndex: number, + style?: ?TextStyleProp, + testID?: ?string, + |}>, + >, +>; + +module.exports = ((requireNativeComponent( + 'RCTPicker', +): any): RCTPickerIOSType); \ No newline at end of file From 5dfd9f3b4a33243e8cbf3c709f361a4249003465 Mon Sep 17 00:00:00 2001 From: Chi-AnTai Date: Tue, 15 Jan 2019 15:45:26 +0800 Subject: [PATCH 2/4] fix Code analysis issues --- Libraries/Components/Picker/RCTPickerNativeComponent.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/Picker/RCTPickerNativeComponent.js b/Libraries/Components/Picker/RCTPickerNativeComponent.js index 3c237f76a49042..2a3e8b5e0d6af0 100644 --- a/Libraries/Components/Picker/RCTPickerNativeComponent.js +++ b/Libraries/Components/Picker/RCTPickerNativeComponent.js @@ -13,6 +13,7 @@ const requireNativeComponent = require('requireNativeComponent'); import type {SyntheticEvent} from 'CoreEventTypes'; import type {TextStyleProp} from 'StyleSheet'; +import type {NativeComponent} from 'ReactNative'; type PickerIOSChangeEvent = SyntheticEvent< $ReadOnly<{| @@ -30,7 +31,7 @@ type RCTPickerIOSItemType = $ReadOnly<{| type Label = Stringish | number; type RCTPickerIOSType = Class< - ReactNative.NativeComponent< + NativeComponent< $ReadOnly<{| items: $ReadOnlyArray, onChange: (event: PickerIOSChangeEvent) => void, @@ -43,6 +44,4 @@ type RCTPickerIOSType = Class< >, >; -module.exports = ((requireNativeComponent( - 'RCTPicker', -): any): RCTPickerIOSType); \ No newline at end of file +module.exports = ((requireNativeComponent('RCTPicker'): any): RCTPickerIOSType); From 51065615ba6b0e66e32ee6f1a4332595783152d5 Mon Sep 17 00:00:00 2001 From: Chi-AnTai Date: Tue, 15 Jan 2019 15:59:07 +0800 Subject: [PATCH 3/4] fix circleCI that missing RCTPickerIOSType --- Libraries/Components/Picker/PickerIOS.ios.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 224ab32eee78d2..b5e29503c73801 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -38,6 +38,20 @@ type RCTPickerIOSItemType = $ReadOnly<{| textColor: ?number, |}>; +type RCTPickerIOSType = Class< + NativeComponent< + $ReadOnly<{| + items: $ReadOnlyArray, + onChange: (event: PickerIOSChangeEvent) => void, + onResponderTerminationRequest: () => boolean, + onStartShouldSetResponder: () => boolean, + selectedIndex: number, + style?: ?TextStyleProp, + testID?: ?string, + |}>, + >, +>; + type Label = Stringish | number; type Props = $ReadOnly<{| From e12683a9d3f3de83cd87b66eb38fd508e7bfe8b0 Mon Sep 17 00:00:00 2001 From: Chi-AnTai Date: Tue, 15 Jan 2019 16:12:55 +0800 Subject: [PATCH 4/4] fix circleIC missing NativeComponent --- Libraries/Components/Picker/PickerIOS.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index b5e29503c73801..1f47a53a97a11e 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -39,7 +39,7 @@ type RCTPickerIOSItemType = $ReadOnly<{| |}>; type RCTPickerIOSType = Class< - NativeComponent< + ReactNative.NativeComponent< $ReadOnly<{| items: $ReadOnlyArray, onChange: (event: PickerIOSChangeEvent) => void,