Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-native-picker/picker

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-picker/picker

React Native Picker for iOS, Android, macOS, and Windows

  • 2.10.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
388K
decreased by-14.73%
Maintainers
1
Weekly downloads
 
Created

What is @react-native-picker/picker?

@react-native-picker/picker is a React Native package that provides a cross-platform Picker component for selecting values from a list. It supports both iOS and Android, offering a consistent user experience across platforms.

What are @react-native-picker/picker's main functionalities?

Basic Picker

This code demonstrates a basic Picker component where users can select between 'Java' and 'JavaScript'. The selected value is displayed above the Picker.

import React, { useState } from 'react';
import { View, Text } from 'react-native';
import { Picker } from '@react-native-picker/picker';

const BasicPicker = () => {
  const [selectedValue, setSelectedValue] = useState('java');

  return (
    <View>
      <Text>Selected: {selectedValue}</Text>
      <Picker
        selectedValue={selectedValue}
        onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
      >
        <Picker.Item label="Java" value="java" />
        <Picker.Item label="JavaScript" value="js" />
      </Picker>
    </View>
  );
};

export default BasicPicker;

Custom Picker Styles

This code demonstrates how to apply custom styles to the Picker component and its container. The Picker is styled to have a specific height and width, and the selected value is displayed with custom text styling.

import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Picker } from '@react-native-picker/picker';

const CustomPicker = () => {
  const [selectedValue, setSelectedValue] = useState('java');

  return (
    <View style={styles.container}>
      <Text style={styles.text}>Selected: {selectedValue}</Text>
      <Picker
        selectedValue={selectedValue}
        style={styles.picker}
        onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
      >
        <Picker.Item label="Java" value="java" />
        <Picker.Item label="JavaScript" value="js" />
      </Picker>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  text: {
    fontSize: 18,
    marginBottom: 10,
  },
  picker: {
    height: 50,
    width: 150,
  },
});

export default CustomPicker;

Picker with Multiple Items

This code demonstrates a Picker component with multiple items. Users can select from 'Java', 'JavaScript', 'Python', and 'C++'. The selected value is displayed above the Picker.

import React, { useState } from 'react';
import { View, Text } from 'react-native';
import { Picker } from '@react-native-picker/picker';

const MultiItemPicker = () => {
  const [selectedValue, setSelectedValue] = useState('java');

  return (
    <View>
      <Text>Selected: {selectedValue}</Text>
      <Picker
        selectedValue={selectedValue}
        onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
      >
        <Picker.Item label="Java" value="java" />
        <Picker.Item label="JavaScript" value="js" />
        <Picker.Item label="Python" value="python" />
        <Picker.Item label="C++" value="cpp" />
      </Picker>
    </View>
  );
};

export default MultiItemPicker;

Other packages similar to @react-native-picker/picker

Keywords

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc