Created
December 13, 2018 03:03
-
-
Save ricexen/d951bf5fb8f0fd5eafe08d75720375b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { View, Picker, StyleSheet } from 'react-native'; | |
import PropTypes from 'prop-types'; | |
const PickerExample = ({elements}) => ( | |
<View> | |
<Picker | |
mode={Platform.OS === 'ios' ? 'dialog' : 'dropdown'} | |
style={styles.picker} | |
selectedValue={this.state.quantityType} | |
onValueChange={this.changeType} | |
itemStyle={styles.pickerItems} | |
> | |
{elements.map(element => <Picker.Item label={element.label} value={element.value}/>)} | |
</Picker> | |
</View> | |
) | |
PickerExample.propTypes = { | |
elements: PropTypes.arrayOf( | |
PropTypes.shape({ | |
label: PropTypes.string, | |
value: PropTypes.string, | |
}) | |
) | |
} | |
const styles = StyleSheet.create({ | |
picker: { | |
flex: 2, | |
backgroundColor: '#E0E0E0', | |
height: 40, | |
}, | |
pickerItems: { | |
height: 40, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment