[fix] Picker supports View props

Close #1064
This commit is contained in:
Michael S. Kazmier
2018-08-08 13:45:55 -06:00
committed by Nicolas Gallagher
parent 2b5ddf753e
commit 744aaa26d4
2 changed files with 9 additions and 3 deletions

View File

@@ -18,10 +18,11 @@ import StyleSheetPropType from '../../modules/StyleSheetPropType';
import StyleSheet from '../StyleSheet';
import TextPropTypes from '../Text/TextPropTypes';
import { arrayOf, bool, func, number, oneOfType, string } from 'prop-types';
import ViewPropTypes, { type ViewProps } from '../ViewPropTypes';
const pickerStyleType = StyleSheetPropType(PickerStylePropTypes);
type Props = {
type Props = ViewProps & {
children?: PickerItem | Array<typeof PickerItem>,
enabled?: boolean,
onValueChange?: Function,
@@ -36,6 +37,7 @@ type Props = {
class Picker extends Component<Props> {
static propTypes = {
...ViewPropTypes,
children: oneOfType([PickerItemPropType, arrayOf(PickerItemPropType)]),
enabled: bool,
onValueChange: func,
@@ -56,8 +58,9 @@ class Picker extends Component<Props> {
/* eslint-disable */
itemStyle,
mode,
prompt
prompt,
/* eslint-enable */
...otherProps
} = this.props;
return createElement('select', {
@@ -66,7 +69,8 @@ class Picker extends Component<Props> {
onChange: this._handleChange,
style: [styles.initial, style],
testID,
value: selectedValue
value: selectedValue,
...otherProps
});
}

View File

@@ -23,6 +23,8 @@ const PickerScreen = () => (
<AppText>Renders the native &lt;select&gt; component.</AppText>
</Description>
<Section title="Props">
<DocItem name="...View props" />
<DocItem
name="children"
typeInfo="?Array<Picker.Item>"