mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 11:57:46 +08:00
Flow strict in Picker.js, PickerIOS.ios.js, PickerAndroid.android.js (#22128)
Summary: Related to #22100 Turn Flow strict mode on for Picker - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android Pull Request resolved: https://github.com/facebook/react-native/pull/22128 Differential Revision: D12946781 Pulled By: mmmulani fbshipit-source-id: 4d3cb884dd8bf57a43ef8aec4491359e9874d182
This commit is contained in:
committed by
Facebook Github Bot
parent
db43aa8fc3
commit
23845fb15c
@@ -32,7 +32,7 @@ type PickerItemProps = $ReadOnly<{|
|
||||
* The value to be passed to picker's `onValueChange` callback when
|
||||
* this item is selected. Can be a string or an integer.
|
||||
*/
|
||||
value?: any,
|
||||
value?: ?(number | string),
|
||||
|
||||
/**
|
||||
* Color of this item's text.
|
||||
@@ -63,14 +63,14 @@ type PickerProps = $ReadOnly<{|
|
||||
/**
|
||||
* Value matching value of one of the items. Can be a string or an integer.
|
||||
*/
|
||||
selectedValue?: any,
|
||||
selectedValue?: ?(number | string),
|
||||
|
||||
/**
|
||||
* Callback for when an item is selected. This is called with the following parameters:
|
||||
* - `itemValue`: the `value` prop of the item that was selected
|
||||
* - `itemPosition`: the index of the selected item in this picker
|
||||
* - `itemIndex`: the index of the selected item in this picker
|
||||
*/
|
||||
onValueChange?: ?(newValue: any, newIndex: number) => mixed,
|
||||
onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed,
|
||||
|
||||
/**
|
||||
* If set to false, the picker will be disabled, i.e. the user will not be able to make a
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -34,18 +34,34 @@ type PickerAndroidChangeEvent = SyntheticEvent<
|
||||
type PickerAndroidProps = $ReadOnly<{|
|
||||
children?: React.Node,
|
||||
style?: ?TextStyleProp,
|
||||
selectedValue?: any,
|
||||
selectedValue?: ?(number | string),
|
||||
enabled?: ?boolean,
|
||||
mode?: ?('dialog' | 'dropdown'),
|
||||
onValueChange?: ?(newValue: any, newIndex: number) => mixed,
|
||||
onValueChange?: ?(itemValue: ?(string | number), itemIndex: number) => mixed,
|
||||
prompt?: ?string,
|
||||
testID?: string,
|
||||
|}>;
|
||||
|
||||
type Item = $ReadOnly<{|
|
||||
label: string,
|
||||
value: ?(number | string),
|
||||
color?: ?number,
|
||||
|}>;
|
||||
|
||||
type PickerAndroidState = {|
|
||||
initialSelectedIndex: number,
|
||||
selectedIndex: number,
|
||||
items: $ReadOnlyArray<Item>,
|
||||
|};
|
||||
|
||||
/**
|
||||
* Not exposed as a public API - use <Picker> instead.
|
||||
*/
|
||||
class PickerAndroid extends React.Component<PickerAndroidProps, *> {
|
||||
|
||||
class PickerAndroid extends React.Component<
|
||||
PickerAndroidProps,
|
||||
PickerAndroidState,
|
||||
> {
|
||||
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
|
||||
* when making Flow check .android.js files. */
|
||||
constructor(props, context) {
|
||||
|
||||
@@ -27,14 +27,14 @@ import type {TextStyleProp} from 'StyleSheet';
|
||||
|
||||
type PickerIOSChangeEvent = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
newValue: any,
|
||||
newValue: number | string,
|
||||
newIndex: number,
|
||||
|}>,
|
||||
>;
|
||||
|
||||
type RCTPickerIOSItemType = $ReadOnly<{|
|
||||
label: ?Label,
|
||||
value: ?any,
|
||||
value: ?(number | string),
|
||||
textColor: ?number,
|
||||
|}>;
|
||||
|
||||
@@ -62,8 +62,8 @@ type Props = $ReadOnly<{|
|
||||
children: React.ChildrenArray<React.Element<typeof PickerIOSItem>>,
|
||||
itemStyle?: ?TextStyleProp,
|
||||
onChange?: ?(event: PickerIOSChangeEvent) => mixed,
|
||||
onValueChange?: ?(newValue: any, newIndex: number) => mixed,
|
||||
selectedValue: any,
|
||||
onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed,
|
||||
selectedValue: ?(number | string),
|
||||
|}>;
|
||||
|
||||
type State = {|
|
||||
@@ -73,7 +73,7 @@ type State = {|
|
||||
|
||||
type ItemProps = $ReadOnly<{|
|
||||
label: ?Label,
|
||||
value?: ?any,
|
||||
value?: ?(number | string),
|
||||
color?: ?ColorValue,
|
||||
|}>;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class PermissionsExample extends React.Component<{}, $FlowFixMeState> {
|
||||
);
|
||||
}
|
||||
|
||||
_onSelectPermission = (permission: string) => {
|
||||
_onSelectPermission = (permission: string | number) => {
|
||||
this.setState({
|
||||
permission: permission,
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ class PickerExample extends React.Component<{}, $FlowFixMeState> {
|
||||
this.setState({mode: newMode});
|
||||
};
|
||||
|
||||
onValueChange = (key: string, value: string) => {
|
||||
onValueChange = (key: string, value: string | number) => {
|
||||
const newState = {};
|
||||
newState[key] = value;
|
||||
this.setState(newState);
|
||||
|
||||
Reference in New Issue
Block a user