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

@react-native-community/picker

Package Overview
Dependencies
Maintainers
40
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/picker

React Native Picker for iOS & Android

  • 1.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
40
Created
Source

@react-native-community/picker

npm version CircleCI Status Supports Android and iOS MIT License Lean Core Extracted

AndroidiOSPickerIOSWindowsMacOS

Supported Versions

@react-native-community/pickerreact-native
>= 1.2.00.60+ or 0.59+ with Jetifier
>= 1.0.00.57

For Managed Workflow users using Expo 37

This component is not supported in the managed workflow for expo sdk 37. Please import the Picker from react-native. See more info here

Getting started

$ npm install @react-native-community/picker --save

or

$ yarn add @react-native-community/picker

For react-native@0.60.0 or above

As react-native@0.60.0 or above supports autolinking, so there is no need to run linking process. Read more about autolinking here.

iOS

CocoaPods on iOS needs this extra step

npx pod-install
Android

No additional step is required.

Windows
Add the ReactNativePicker project to your solution.
  1. Open the solution in Visual Studio 2019
  2. Right-click Solution icon in Solution Explorer > Add > Existing Project Select D:\dev\RNTest\node_modules\@react-native-community\picker\windows\ReactNativePicker\ReactNativePicker.vcxproj
windows/myapp.sln

Add a reference to ReactNativePicker to your main application project. From Visual Studio 2019:

Right-click main application project > Add > Reference... Check ReactNativePicker from Solution Projects.

pch.h

Add #include "winrt/ReactNativePicker.h".

app.cpp

Add PackageProviders().Append(winrt::ReactNativePicker::ReactPackageProvider()); before InitializeComponent();.

MacOS

CocoaPods on MacOS needs this extra step (called from the MacOS directory)

pod install

Mostly automatic installation (react-native < 0.60)

$ react-native link @react-native-community/picker

Manual installation (react-native < 0.60)

iOS
  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules @react-native-community/picker and add RNCPicker.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNCPicker.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<
Android
  1. Open application file (android/app/src/main/java/[...]/MainApplication.java)
  • Add import com.reactnativecommunity.picker.RNCPickerPackage; to the imports at the top of the file
  • Add new RNCPickerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ': @react-native-community/picker'
    project(': @react-native-community/picker').projectDir = new File(rootProject.projectDir, 	'../node_modules/@react-native-community/picker/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(path: ':@react-native-community_picker')
    
MacOS
  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules @react-native-community/picker and add RNCPicker.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNCPicker.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Usage

Picker

Renders the native picker component on iOS and Android. Example:

Usage

Import Picker from @react-native-community/picker

import {Picker} from '@react-native-community/picker';

Create state which will be used by the Picker

state = {
  language: 'java',
};

Add Picker like this:

<Picker
  selectedValue={this.state.language}
  style={{height: 50, width: 100}}
  onValueChange={(itemValue, itemIndex) =>
    this.setState({language: itemValue})
  }>
  <Picker.Item label="Java" value="java" />
  <Picker.Item label="JavaScript" value="js" />
</Picker>

Props


Reference

Props

onValueChange

Callback for when an item is selected. This is called with the following parameters:

  • itemValue: the value prop of the item that was selected
  • itemPosition: the index of the selected item in this picker
TypeRequired
functionNo

selectedValue

Value matching value of one of the items. Can be a string or an integer.

TypeRequired
anyNo

style

TypeRequired
pickerStyleTypeNo

testID

Used to locate this view in end-to-end tests.

TypeRequired
stringNo

enabled

If set to false, the picker will be disabled, i.e. the user will not be able to make a selection.

TypeRequiredPlatform
boolNoAndroid, Windows

mode

On Android, specifies how to display the selection items when the user taps on the picker:

  • 'dialog': Show a modal dialog. This is the default.
  • 'dropdown': Shows a dropdown anchored to the picker view
TypeRequiredPlatform
enum('dialog', 'dropdown')NoAndroid

prompt

Prompt string for this picker, used on Android in dialog mode as the title of the dialog.

TypeRequiredPlatform
stringNoAndroid

itemStyle

Style to apply to each of the item labels.

TypeRequiredPlatform
text stylesNoiOS, Windows

PickerIOS

Props


Reference

Props

itemStyle

TypeRequired
text stylesNo

onValueChange

TypeRequired
functionNo

selectedValue

TypeRequired
anyNo

Keywords

FAQs

Package last updated on 09 Oct 2020

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