Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-element-dropdown
Advanced tools
A react-native dropdown component easy to customize for both iOS and Android.
A React Native dropdown component easy to customize for both iOS and Android.
npm install react-native-element-dropdown --save
or
yarn add react-native-element-dropdown
react-native link react-native-element-dropdown
pod install
react-native run-ios
react-native run-android
react-native-template-components A beautiful template for React Native.
Props | Params | isRequire | Description |
---|---|---|---|
data | Array | Yes | Data is a plain array |
labelField | String | Yes | Extract the label from the data item |
valueField | String | Yes | Extract the primary key from the data item |
onChange | (item) => void | Yes | Selection callback |
value | Item | No | Selected value |
placeholder | String | No | The string that will be rendered before dropdown has been selected |
placeholderStyle | TextStyle | No | Styling for text placeholder |
selectedTextStyle | TextStyle | No | Styling for selected text |
selectedTextProps | TextProps | No | Text Props for selected text. Ex: numberOfLines={1} |
style | ViewStyle | No | Styling for container view |
containerStyle | ViewStyle | No | Styling for container list |
maxHeight | Number | No | Customize height for container list |
fontFamily | String | No | Customize font style |
iconColor | String | No | Color of icons |
activeColor | String | No | Background color for item selected in container list |
search | Boolean | No | Show or hide input search |
inputSearchStyle | ViewStyle | No | Styling for input search |
searchPlaceholder | String | No | The string that will be rendered before text input has been entered |
renderInputSearch | (onSearch: (text:string) => void) => JSX.Element | No | Customize TextInput search |
disable | Boolean | No | Specifies the disabled state of the Dropdown |
autoScroll | Boolean | No | Auto scroll to index item selected, default is true |
showsVerticalScrollIndicator | Boolean | No | When true, shows a vertical scroll indicator, default is true |
renderLeftIcon | () => JSX.Element | No | Customize left icon for dropdown |
renderRightIcon | () => JSX.Element | No | Customize right icon for dropdown |
renderItem | (item) => JSX.Element | No | Takes an item from data and renders it into the list |
onFocus | () => void | No | Callback that is called when the dropdown is focused |
onBlur | () => void | No | Callback that is called when the dropdown is blurred |
Props | Params | isRequire | Description |
---|---|---|---|
data | Array | Yes | Data is a plain array |
labelField | String | Yes | Extract the label from the data item |
valueField | String | Yes | Extract the primary key from the data item |
onChange | (value[]) => void | Yes | Selection callback |
value | Item[] | No | Selected value |
placeholder | String | No | The string that will be rendered before dropdown has been selected |
placeholderStyle | TextStyle | No | Styling for text placeholder |
style | ViewStyle | No | Styling for container view |
containerStyle | ViewStyle | No | Styling for container list |
maxHeight | Number | No | Customize height for container list |
fontFamily | String | No | Customize font style |
iconColor | String | No | Color of icons |
activeColor | String | No | Background color for item selected in container list |
selectedStyle | ViewStyle | No | Styling for selected view |
selectedTextStyle | TextStyle | No | Styling for selected text |
renderSelectedItem | (item, unSelect?: (item) => void) => JSX.Element | No | Takes an item from data and renders it into the list selected |
search | Boolean | No | Show or hide input search |
inputSearchStyle | ViewStyle | No | Styling for input search |
searchPlaceholder | String | No | The string that will be rendered before text input has been entered |
renderInputSearch | (onSearch: (text:string) => void) => JSX.Element | No | Customize TextInput search |
disable | Boolean | No | Specifies the disabled state of the Dropdown |
showsVerticalScrollIndicator | Boolean | No | When true, shows a vertical scroll indicator, default is true |
renderLeftIcon | () => JSX.Element | No | Customize left icon for dropdown |
renderRightIcon | () => JSX.Element | No | Customize right icon for dropdown |
renderItem | (item) => JSX.Element | No | Takes an item from data and renders it into the list |
onFocus | () => void | No | Callback that is called when the dropdown is focused |
onBlur | () => void | No | Callback that is called when the dropdown is blurred |
Props | Params | isRequire | Description |
---|---|---|---|
imageField | String | Yes | Extract the image from the data item |
imageStyle | ImageStyle | No | Styling for image |
import React, {useState} from 'react';
import {StyleSheet, View, Text, Image} from 'react-native';
import {Dropdown, MultiSelect} from 'react-native-element-dropdown';
const data = [
{label: 'Item 1', value: '1'},
{label: 'Item 2', value: '2'},
{label: 'Item 3', value: '3'},
{label: 'Item 4', value: '4'},
{label: 'Item 5', value: '5'},
{label: 'Item 6', value: '6'},
{label: 'Item 7', value: '7'},
{label: 'Item 8', value: '8'},
];
const DropdownScreen = _props => {
const [dropdown, setDropdown] = useState(null);
const [selected, setSelected] = useState([]);
const _renderItem = item => {
return (
<View style={styles.item}>
<Text style={styles.textItem}>{item.label}</Text>
<Image style={styles.icon} source={require('./assets/tick.png')} />
</View>
);
};
return (
<View style={styles.container}>
<Dropdown
style={styles.dropdown}
data={data}
search
searchPlaceholder="Search"
labelField="label"
valueField="value"
placeholder="Select item"
value={dropdown}
onChange={item => {
setDropdown(item.value);
console.log('selected', item);
}}
renderLeftIcon={() => (
<Image style={styles.icon} source={require('./assets/account.png')} />
)}
renderItem={item => _renderItem(item)}
/>
<MultiSelect
style={styles.dropdown2}
data={data}
labelField="label"
valueField="value"
placeholder="Select item"
search
searchPlaceholder="Search"
value={selected}
onChange={item => {
setSelected(item);
console.log('selected', item);
}}
renderItem={item => _renderItem(item)}
/>
</View>
);
};
export default DropdownScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
padding: 40,
},
dropdown: {
backgroundColor: 'white',
borderBottomColor: 'gray',
borderBottomWidth: 0.5,
marginTop: 20,
},
dropdown2: {
backgroundColor: 'white',
borderColor: 'gray',
borderWidth: 0.5,
marginTop: 20,
padding: 8,
},
icon: {
marginRight: 5,
width: 18,
height: 18,
},
item: {
paddingVertical: 17,
paddingHorizontal: 4,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
textItem: {
flex: 1,
fontSize: 16,
},
});
FAQs
React Native Element Dropdown is a library that provides a customizable dropdown component for React Native applications.
The npm package react-native-element-dropdown receives a total of 57,318 weekly downloads. As such, react-native-element-dropdown popularity was classified as popular.
We found that react-native-element-dropdown demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.