Skip to content

Commit 6c18069

Browse files
Chi-AnTaifacebook-github-bot
authored andcommitted
RCTPicker (facebook#22996)
Summary: [iOS] [Changed] - As facebook#22990 said, move requireNativeComponent to a separate file. I am not familiar with flow, I try to follow the https://pastebin.com/RFpdT76V example but I am not sure I have done it right. Pull Request resolved: facebook#22996 Differential Revision: D13697082 Pulled By: cpojer fbshipit-source-id: c0c87a8e1a7f0553da994aba230f69b496140200
1 parent 1af390b commit 6c18069

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

Libraries/Components/Picker/PickerIOS.ios.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const ReactNative = require('ReactNative');
1818
const StyleSheet = require('StyleSheet');
1919
const View = require('View');
2020
const processColor = require('processColor');
21-
const requireNativeComponent = require('requireNativeComponent');
21+
const RCTPickerNativeComponent = require('RCTPickerNativeComponent');
2222

2323
import type {SyntheticEvent} from 'CoreEventTypes';
2424
import type {ColorValue} from 'StyleSheetTypes';
@@ -52,10 +52,6 @@ type RCTPickerIOSType = Class<
5252
>,
5353
>;
5454

55-
const RCTPickerIOS: RCTPickerIOSType = (requireNativeComponent(
56-
'RCTPicker',
57-
): any);
58-
5955
type Label = Stringish | number;
6056

6157
type Props = $ReadOnly<{|
@@ -111,7 +107,7 @@ class PickerIOS extends React.Component<Props, State> {
111107
render() {
112108
return (
113109
<View style={this.props.style}>
114-
<RCTPickerIOS
110+
<RCTPickerNativeComponent
115111
ref={picker => {
116112
this._picker = picker;
117113
}}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
*/
10+
'use strict';
11+
12+
const requireNativeComponent = require('requireNativeComponent');
13+
14+
import type {SyntheticEvent} from 'CoreEventTypes';
15+
import type {TextStyleProp} from 'StyleSheet';
16+
import type {NativeComponent} from 'ReactNative';
17+
18+
type PickerIOSChangeEvent = SyntheticEvent<
19+
$ReadOnly<{|
20+
newValue: number | string,
21+
newIndex: number,
22+
|}>,
23+
>;
24+
25+
type RCTPickerIOSItemType = $ReadOnly<{|
26+
label: ?Label,
27+
value: ?(number | string),
28+
textColor: ?number,
29+
|}>;
30+
31+
type Label = Stringish | number;
32+
33+
type RCTPickerIOSType = Class<
34+
NativeComponent<
35+
$ReadOnly<{|
36+
items: $ReadOnlyArray<RCTPickerIOSItemType>,
37+
onChange: (event: PickerIOSChangeEvent) => void,
38+
onResponderTerminationRequest: () => boolean,
39+
onStartShouldSetResponder: () => boolean,
40+
selectedIndex: number,
41+
style?: ?TextStyleProp,
42+
testID?: ?string,
43+
|}>,
44+
>,
45+
>;
46+
47+
module.exports = ((requireNativeComponent('RCTPicker'): any): RCTPickerIOSType);

0 commit comments

Comments
 (0)