
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
react-native-picker-w-icon
Advanced tools
$ npm install react-native-picker-w-icon --save
$ react-native link react-native-picker-w-icon
import React, { useState } from "react";
import PickerWIcon from 'react-native-picker-w-icon';
import { View, Image, StyleSheet } from "react-native";
import { Icon } from "native-base";
const telCodes = [
{
"code": "+60",
"icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-21-256.png",
},
{
"code": "+62",
"icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-27-128.png",
},
{
"code": "+81",
"icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-16-256.png",
},
]
const PickerWIconApp = props => {
const [value, setValue] = useState(undefined);
return (
<PickerWIcon
options={telCodes}
dropdownStyle={{ height: (50 + StyleSheet.hairlineWidth) * telCodes.length }}
defaultValue={telCodes[0]}
onSelect={(index, value) => setValue(value)}
renderRow={
<View>
<Image
source={{ uri: telCodes[0].icon }}
style={{ width: 30, height: 30 }}
resizeMode={'cover'}
/>
<Text numberOfLines={1}>
{telCodes[0].code}
</Text>
<Icon
name="md-arrow-dropdown"
style={{ color: 'transparent' }}
/>
</View>
}
selected={
<View style={styles.button}>
<Image
source={{ uri: value.icon }}
style={styles.iconStyle}
/>
<Text style={styles.buttonText} numberOfLines={1}>
{value.code}
</Text>
<Icon
name="md-caret-down"
style={styles.pickerIcon}
/>
</View>
}
/>
)
}
var styles = StyleSheet.create({
button: {
justifyContent: 'space-evenly',
alignItems: 'center',
flexDirection: 'row',
height: 50
},
buttonText: {
fontSize: 16,
color: 'white'
},
pickerIcon: {
color: 'grey',
width: 23,
height: 28
},
iconStyle: {
width: 30,
height: 30
},
});
Prop | Type | Required | Default | Description |
---|---|---|---|---|
options | Array | Yes | Array of objects to select | |
selected | component | Yes | The selected component | |
renderRow | component | Yes | The component to show in the dropdown | |
disabled | bool | No | false | Disables interaction with the component |
scrollEnabled | bool | No | true | Scrollable |
showItemSeparator | bool | No | false | Show item separator between dropdown item |
defaultValue | object | No | options[0] | Default selected value |
animated | bool | No | true | Animation of showing the dropdown list |
showsVerticalScrollIndicator | bool | No | false | Show vertical scroll indicator of the list |
style | style | No | The style applied to the option container | |
dropdownStyle | style | No | The style of the dropdown | |
dropdownTextStyle | style | No | The style of the drop down text |
MIT Licensed
FAQs
React Native Picker with Icon
We found that react-native-picker-w-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.