Skip to content

Commit 1c66cdc

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Flowtype PickerIOS
Reviewed By: yungsters Differential Revision: D7985960 fbshipit-source-id: 9fbce5fafe47bee1d2a527c72f3ebef85d26f9f1
1 parent d796129 commit 1c66cdc

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Libraries/Components/Picker/PickerIOS.ios.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
const NativeMethodsMixin = require('NativeMethodsMixin');
1616
const React = require('React');
17+
const ReactNative = require('ReactNative');
1718
const PropTypes = require('prop-types');
1819
const StyleSheet = require('StyleSheet');
1920
const StyleSheetPropType = require('StyleSheetPropType');
@@ -26,6 +27,17 @@ const createReactClass = require('create-react-class');
2627
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
2728
const requireNativeComponent = require('requireNativeComponent');
2829

30+
import type {ColorValue} from 'StyleSheetTypes';
31+
import type {ViewProps} from 'ViewPropTypes';
32+
33+
type Props = $ReadOnly<{|
34+
...ViewProps,
35+
color?: ?ColorValue,
36+
label: string,
37+
testID?: ?string,
38+
value?: ?any,
39+
|}>;
40+
2941
const PickerIOS = createReactClass({
3042
displayName: 'PickerIOS',
3143
mixins: [NativeMethodsMixin],
@@ -106,7 +118,13 @@ const PickerIOS = createReactClass({
106118
},
107119
});
108120

109-
PickerIOS.Item = class extends React.Component {
121+
PickerIOS.Item = class extends React.Component<
122+
$ReadOnly<{|
123+
label: string,
124+
value?: ?any,
125+
color?: ?ColorValue,
126+
|}>,
127+
> {
110128
static propTypes = {
111129
value: PropTypes.any, // string or integer basically
112130
label: PropTypes.string,
@@ -119,6 +137,10 @@ PickerIOS.Item = class extends React.Component {
119137
}
120138
};
121139

140+
class TypedPickerIOS extends ReactNative.NativeComponent<Props> {
141+
static Item = PickerIOS.Item;
142+
}
143+
122144
const styles = StyleSheet.create({
123145
pickerIOS: {
124146
// The picker will conform to whatever width is given, but we do
@@ -144,4 +166,4 @@ const RCTPickerIOS = requireNativeComponent(
144166
},
145167
);
146168

147-
module.exports = PickerIOS;
169+
module.exports = ((PickerIOS: any): Class<TypedPickerIOS>);

0 commit comments

Comments
 (0)