Skip to content

Commit

Permalink
Merge pull request #26 from TimMun/master
Browse files Browse the repository at this point in the history
Pass color prop to PickerItem
  • Loading branch information
lfkwtz authored Jun 5, 2018
2 parents 2e7f876 + 3b732b3 commit 3370509
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For either platform, you can alternatively pass down a child element that will b
| Name | Type | Description | Required? | iOS / Android |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------- |
| onValueChange | function | Callback which returns `value, index` | Y | Both |
| items | array | _ The items for the component to render. Each item should be in the following format:<br>`{label: 'Orange',value: 'orange',key: 'orange'}`<br>_ The label and the value are required, but the key will be based upon the label if it isn't included<br>\* The value can be any data type | Y | Both |
| items | array | _ The items for the component to render. Each item should be in the following format:<br>`{label: 'Orange',value: 'orange',key: 'orange', color: 'orange'}`<br>_ The label and the value are required, but the key will be based upon the label if it isn't included<br>\* The value can be any data type. The color is optional. | Y | Both |
| placeholder | object | _ An override for the default placeholder object with a label of `Select an item...` and a value of `null`<br>_ An empty object can be used if you'd like to disable the placeholder entirely | N | Both |
| disabled | boolean | Disables interaction with the component | N | Both |
| value | any | Will attempt to locate a matching value from the `items` array by checking each item's `value` property. If found, it will update the component to show that item as selected. If the value is not found, it will default to the first item. | N | Both |
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Picker,
Platform,
StyleSheet,
ColorPropType,
Text,
TextInput,
TouchableOpacity,
Expand Down Expand Up @@ -108,7 +109,7 @@ export default class RNPickerSelect extends PureComponent {
renderPickerItems() {
return this.state.items.map((item) => {
return (
<Picker.Item label={item.label} value={item.value} key={item.key || item.label} />
<Picker.Item label={item.label} value={item.value} key={item.key || item.label} color={item.color} />
);
});
}
Expand Down Expand Up @@ -300,6 +301,7 @@ RNPickerSelect.propTypes = {
label: PropTypes.string.isRequired,
value: PropTypes.any.isRequired,
key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
color: ColorPropType
})
).isRequired,
placeholder: PropTypes.shape({
Expand Down

0 comments on commit 3370509

Please sign in to comment.