Coder Social home page Coder Social logo

react-native-picker / picker Goto Github PK

View Code? Open in Web Editor NEW
1.4K 15.0 272.0 135.92 MB

Picker is a cross-platform UI component for selecting an item from a list of options.

License: MIT License

Java 25.57% JavaScript 21.72% Objective-C 6.03% Ruby 2.75% Starlark 0.24% C++ 22.06% TypeScript 12.22% Makefile 0.62% Objective-C++ 7.04% C 0.16% Kotlin 0.99% CMake 0.59%
react-native picker ios android macos windows hacktoberfest

picker's Introduction

@react-native-picker/picker

npm version Build Supports Android, iOS, MacOS, and Windows MIT License Lean Core Extracted

Android iOS PickerIOS Windows MacOS

Supported Versions

@react-native-picker/picker react-native react-native-windows
>= 2.0.0 0.61+ 0.64+
>= 1.16.0 0.61+ 0.61+
>= 1.2.0 0.60+ or 0.59+ with Jetifier N/A
>= 1.0.0 0.57 N/A

Getting started

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

or

$ yarn add @react-native-picker/picker

For React Native v0.60 and above (Autolinking)

As [email protected] and above supports autolinking there is no need to run the linking process. Read more about autolinking here. This is supported by [email protected] and above.

iOS

CocoaPods on iOS needs this extra step:

npx pod-install

Android

No additional step is required.

Windows (expand for details)

Windows

Usage in Windows without autolinking requires the following extra steps:

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-picker\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.

app.cpp

Add #include "winrt/ReactNativePicker.h" to the headers included at the top of the file.

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

MacOS

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

pod install
React Native below 0.60 (Link and Manual Installation)

The following steps are only necessary if you are working with a version of React Native lower than 0.60

Mostly automatic installation

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

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules @react-native-picker/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-picker_picker'
    project(':@react-native-picker_picker').projectDir = new File(rootProject.projectDir, 	'../node_modules/@react-native-picker/picker/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(path: ':@react-native-picker_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-picker/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)<

RTL Support

you need to add android:supportsRtl="true" to AndroidManifest.xml

   <application
      ...
      android:supportsRtl="true">

Usage

Import Picker from @react-native-picker/picker:

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

Create state which will be used by the Picker:

const [selectedLanguage, setSelectedLanguage] = useState();

Add Picker like this:

<Picker
  selectedValue={selectedLanguage}
  onValueChange={(itemValue, itemIndex) =>
    setSelectedLanguage(itemValue)
  }>
  <Picker.Item label="Java" value="java" />
  <Picker.Item label="JavaScript" value="js" />
</Picker>

If you want to open/close picker programmatically on android (available from version 1.16.0+), pass ref to Picker:

const pickerRef = useRef();

function open() {
  pickerRef.current.focus();
}

function close() {
  pickerRef.current.blur();
}

return <Picker
  ref={pickerRef}
  selectedValue={selectedLanguage}
  onValueChange={(itemValue, itemIndex) =>
    setSelectedLanguage(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
Type Required
function No

selectedValue

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

Type Required
any No

style

Type Required
pickerStyleType No

testID

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

Type Required
string No

enabled

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

Type Required Platform
bool No Android, Web, 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
Type Required Platform
enum('dialog', 'dropdown') No Android

dropdownIconColor

On Android, specifies color of dropdown triangle. Input value should be value that is accepted by react-native processColor function.

Type Required Platform
ColorValue No Android

dropdownIconRippleColor

On Android, specifies ripple color of dropdown triangle. Input value should be value that is accepted by react-native processColor function.

Type Required Platform
ColorValue No Android

prompt

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

Type Required Platform
string No Android

itemStyle

Style to apply to each of the item labels.

Type Required Platform
text styles No iOS, Windows

numberOfLines

On Android & iOS, used to truncate the text with an ellipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number. Default is '1'

Type Required Platform
number No Android, iOS

onBlur

Type Required Platform
function No Android

onFocus

Type Required Platform
function No Android

selectionColor

Type Required Platform
ColorValue No iOS

Methods

blur (Android only, lib version 1.16.0+)

Programmatically closes picker

focus (Android only, lib version 1.16.0+)

Programmatically opens picker

PickerItemProps

Props that can be applied to individual Picker.Item

label

Displayed value on the Picker Item

Type Required
string Yes

value

Actual value on the Picker Item

Type Required
number,string Yes

color

Displayed color on the Picker Item

Type Required
ColorValue No

fontFamily

Displayed fontFamily on the Picker Item

Type Required
string No

style

Style to apply to individual item labels.

Type Required Platform
ViewStyleProp No Android

enabled

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

@default: true

Type Required Platform
boolean No Android

contentDescription

Sets the content description to the Picker Item

Type Required Platform
string No Android

PickerIOS

Props


Reference

Props

itemStyle

Type Required
text styles No

onValueChange

Type Required
function No

selectedValue

Type Required
any No

selectionColor

Type Required Platform
ColorValue No iOS

themeVariant

Type Required
enum('light', 'dark') No

picker's People

Contributors

a-c-sreedhar-reddy avatar alanjhughes avatar bartolkaruza avatar bestander avatar bralax avatar brumor avatar cesargdm avatar chakrihacker avatar chiaramooney avatar christophpurrer avatar davidaurelio avatar dependabot[bot] avatar evanbacon avatar jainkuniya avatar javache avatar jbrown215 avatar mateusz1913 avatar maximilize avatar mojodna avatar naturalclar avatar nickgerleman avatar nicklockwood avatar nissy-dev avatar olvipi avatar rickhanlonii avatar semantic-release-bot avatar sophiebits avatar thesavior avatar vjeux avatar yungsters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picker's Issues

PickerIOS is alway showing in React-Native.

Bug

Environment info

react-native info output:

   "react": "16.9.0",
    "react-native": "0.61.5",
  

Library version: @react-native-community/picker": "^1.3.0",

Reproducible sample code

import {Picker} from '@react-native-community/picker';
import {FormLabel} from '../TextField';
import {colors, textStyle, usStates} from '../../../Constants';

export default function CustomPicker({value, name, onChangeText}) {
  return (
    <FormLabel label="Select state" labelStyles={[textStyle.captionRegular, {color: colors.dust_grey}]}>
      <Picker mode="dropdown" selectedValue={value} style={[(textStyle.subTitleRegular, {color: colors.black, marginLeft: -5})]} onValueChange={(itemValue, itemIndex) => onChangeText(name, itemValue)}>
        <Picker.Item label={'Choose State'} value={''} />
        {usStates.map((state, index) => (
          <Picker.Item key={index} label={state.name} value={state.abbreviation} />
        ))}
      </Picker>
    </FormLabel>
  );

Warning message about the future of the react-native-picker-select component.

I received the next warning message, I don't know if important for the future, if can give me problems in my application.

Exist any way to do disappear?

Warning: Picker has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/picker' instead of 'react-native'. See https://github.com/react-native-community/react-native-picker

Regards, and thank you for your help.

Javier.

Duplicate Types from @types/react-native

Bug

Adding this new Picker lib to a React Native TypeScript project is causing compilation errors (related to duplicate identifiers) when running tsc.

node_modules/@react-native-community/picker/typings/Picker.d.ts:56:15 - error TS2300: Duplicate identifier 'Picker'.

56 declare class Picker extends React.Component<PickerProps, {}> {
                 ~~~~~~

node_modules/@react-native-community/picker/typings/Picker.d.ts:56:15 - error TS2395: Individual declarations in merged declaration 'Picker' must be all exported or all local.

56 declare class Picker extends React.Component<PickerProps, {}> {
                 ~~~~~~

node_modules/@react-native-community/picker/typings/Picker.d.ts:69:14 - error TS2300: Duplicate identifier 'Picker'.

69 export const Picker;
                ~~~~~~

node_modules/@react-native-community/picker/typings/Picker.d.ts:69:14 - error TS2395: Individual declarations in merged declaration 'Picker' must be all exported or all local.

69 export const Picker;
                ~~~~~~

node_modules/@react-native-community/picker/typings/Picker.d.ts:69:14 - error TS7005: Variable 'Picker' implicitly has an 'any' type.

69 export const Picker;
                ~~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:12:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

12 class PickerIOSItem extends React.Component<PickerIOSItemProps, {}> {}
   ~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:23:15 - error TS2300: Duplicate identifier 'PickerIOS'.

23 declare class PickerIOS extends React.Component<PickerIOSProps, {}> {
                 ~~~~~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:23:15 - error TS2395: Individual declarations in merged declaration 'PickerIOS' must be all exported or all local.

23 declare class PickerIOS extends React.Component<PickerIOSProps, {}> {
                 ~~~~~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:27:14 - error TS2300: Duplicate identifier 'PickerIOS'.

27 export const PickerIOS;
                ~~~~~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:27:14 - error TS2395: Individual declarations in merged declaration 'PickerIOS' must be all exported or all local.

27 export const PickerIOS;
                ~~~~~~~~~

node_modules/@react-native-community/picker/typings/PickerIOS.d.ts:27:14 - error TS7005: Variable 'PickerIOS' implicitly has an 'any' type.

27 export const PickerIOS;

Environment info

react-native info output:

System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 4.74 GB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.0 - /Users/brent.kelly/.rvm/gems/ruby-2.6.3/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2, 29.0.3
      System Images: android-21 | Intel x86 Atom_64, android-22 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | ARM 64 v8a, android-25 | Intel x86 Atom_64, android-27 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6308749
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_201 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 1.3.0

Steps To Reproduce

Create new RN project

npx react-native init PickerTypes --template react-native-template-typescript

Add the Picker lib

yarn add @react-native-community/picker

Import Picker in App.tsx

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

Compile TypeScript

yarn tsc

Describe what you expected to happen:

TypeScript compile should return no compilation failures.

Reproducible sample code

touch area for items very small / unusable on android

I have not found a way to increase or position the items in the android picker. Is there a way to do that? Especially the non-dropdown mode with a set width becomes very buggy this way.

If this is not adaptable I don't see how this package can be used on android.

Android styles

Setting styles on android device is the biggest disaster

Side-by-side/multi-column pickers? (For dates, times)

Feature Request

I'd like to get off of react-native-picker which hasn't been updated in 2 years. I'm using it to create an hours/minutes/seconds multicolumn picker. Is there a simple way to do that with this library?

Why it is needed

These kinds of pickers are fairly common, e.g. selecting Date/Time in the iOS Reminders app

Code sample

Something like:

<Picker columns={ list1, list2, list3 } />

Related pickers crashes the app

It seems impossible to bind two pickers together (one changing depending on the value of the other) because in 99% of cases the app crashes. It's a bug somewhere in the RN code which I was not able to workaround. The snippet below should make everything clears.

For now, I was forced to replace the pickers with custom modals.

React Native version:
System:
OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish)
CPU: (4) x64 Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
Memory: 1.91 GB / 3.73 GB
Shell: Unknown - /bin/mksh
Binaries:
Node: 8.11.4 - /usr/bin/node
npm: 6.10.3 - /usr/local/bin/npm
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-screens: 1.0.0-alpha.23

Steps To Reproduce

  1. Run the code below
  2. Select Bar > BarSub02 then go back to Foo

I expect to find Foo > FooSub01 selected. I get a FATAL EXCEPTION instead.

Following code example is a reproducible test case:

import React, {Component} from "react";
import {
        Picker,
        View
} from "react-native";

export default class PickerTest extends Component {
        constructor(props) {
                super(props);
                this.state = {
                        index_group: 0,
                        index_subgroup: 0,
                        items: [
                                {name:"Foo", subs: [
                                        {ClsSubGrName:"FooSub01"},
                                ]},
                                {name:"Bar", subs: [
                                        {ClsSubGrName:"BarSub01"},
                                        {ClsSubGrName:"BarSub02"}
                                ]}
                        ]
                };
        }

        render() {
                return (
                <View style={{flex:1}}>
                        <Picker
                                selectedValue={this.state.index_group}
                                onValueChange={(v) => this.setState({index_group:v,index_subgroup:0})}>
                                {this.state.items.map((item, i) => (
                                        <Picker.Item key={i} value={i} label={item.name} />
                                ))}
                        </Picker>

                        <Picker
                                selectedValue={this.state.index_subgroup}
                                onValueChange={(v) => this.setState({index_subgroup:v})}>
                                {this.state.items[this.state.index_group].subs.map((item, i) => (
                                        <Picker.Item key={i} value={i} label={item.ClsSubGrName} />
                                ))}
                        </Picker>
                </View>
                )
        }
}

Notice that the issue does not occur if current item is the first in list or if you switch between groups with more than one item (e.g. if you add FooSub02 under Foo the issue should not happen anymore).

Here's an excerpt from my logs:

08-09 13:11:27.589  3658  3658 E unknown:ReactNative: Exception in native call
08-09 13:11:27.589  3658  3658 E unknown:ReactNative: java.lang.ArrayIndexOutOfBoundsException: length=1; index=3
08-09 13:11:27.589  3658  3658 E unknown:ReactNative:   at java.util.Arrays$ArrayList.get(Arrays.java:3854)
[ ...OMISSIS... ]
08-09 13:11:27.594  3658  3658 D AndroidRuntime: Shutting down VM
08-09 13:11:27.595  3658  3658 E AndroidRuntime: FATAL EXCEPTION: main

Possible to edit implementation of RCTPicker.m in the ios folder?

Hi, I wanted to add some custom behavior to the underlying native IOS Picker and I was attempting to make changes to the RCTPicker.m file but I wasn't able to see the changes reflected in my app.

Is it possible to edit this implementation, and if so, do I have to make some sort of local patch or re-build in a certain way, etc?

Would appreciate any help or pointers

node_modules/@react-native-community/picker/android/src/main/java/com/reactnativecommunity/picker/ReactPicker.java:11: error: package android.support.v7.widget does not exist import android.support.v7.widget.AppCompatSpinner;

I have the suspicion, that this is caused by the lack of androidX support. If that is the case, this should be a feature request to support androidX

or maybe a failure to autolink? I thought it should work according to this closed issue

Edit: It seems to be indeed an autolinking issue.

Add Typescript types.

Typescript type definitions are currently not exported. An example of where they should be and what this looks like is in the cameraroll repo here.

Invariant Violation: requireNativeComponent: "RNCPicker" was not found in the UIManager.

Bug

I am unable to get this to work. I'm receiving the following error

`Violation: requireNativeComponent: "RNCPicker" was not found in the UIManager.

This error is located at:
in RNCPicker (at PickerIOS.ios.js:107)
in RCTView (at View.js:35)
in View (at PickerIOS.ios.js:106)
in PickerIOS (at Picker.js:142)
in Picker (at edit-exercise.modal.tsx:54)
in EditExerciseModal (created by inject-with-exerciseStore(EditExerciseModal))
in inject-with-exerciseStore(EditExerciseModal) (at SceneView.js:9)
in SceneView (at StackViewLayout.tsx:909)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.tsx:106)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:71)
in Screen (at StackViewCard.tsx:93)
in Card (at createPointerEventsContainer.tsx:95)
in Container (at StackViewLayout.tsx:984)
in RCTView (at View.js:35)
in View (at screens.native.js:101)
in ScreenContainer (at StackViewLayout.tsx:393)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.tsx:383)
in PanGestureHandler (at StackViewLayout.tsx:376)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.tsx:104)
in RCTView (at View.js:35)
in View (at Transitioner.tsx:267)
in Transitioner (at StackView.tsx:41)
in StackView (at createNavigator.js:80)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at SceneView.js:9)
in SceneView (at StackViewLayout.tsx:909)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.tsx:106)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:71)
in Screen (at StackViewCard.tsx:93)
in Card (at createPointerEventsContainer.tsx:95)
in Container (at StackViewLayout.tsx:984)
in RCTView (at View.js:35)
in View (at screens.native.js:101)
in ScreenContainer (at StackViewLayout.tsx:393)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.tsx:383)
in PanGestureHandler (at StackViewLayout.tsx:376)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.tsx:104)
in RCTView (at View.js:35)
in View (at Transitioner.tsx:267)
in Transitioner (at StackView.tsx:41)
in StackView (at createNavigator.js:80)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at SceneView.js:9)
in SceneView (at SwitchView.js:12)
in SwitchView (at createNavigator.js:80)
in Navigator (at createAppContainer.js:430)
in NavigationContainer (at root-component.tsx:73)
in RCTView (at View.js:35)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at react-native-safe-area-view/index.js:163)
in SafeView (at withOrientation.js:54)
in withOrientation (at root-component.tsx:71)
in BackButtonHandler (at root-component.tsx:70)
in MobXProvider (at root-component.tsx:69)
in RootComponent (at renderApplication.js:40)
in RCTView (at View.js:35)
in View (at AppContainer.js:98)
in RCTView (at View.js:35)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:39)`

Environment info

OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 18.22 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash

Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.2/11B52 - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: ^2.9.0 => 2.9.0
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1

Describe what you expected to happen:

I expected the spinner to show but i received this error. I used the sample code in the readme

Tried to register two views with the same name AndroidDropdownPicker

all the package are updated, the picker is work very well
import {Picker} from '@react-native-community/picker';

but when i import button from native base i got this error
Tried to register two views with the same name AndroidDropdownPicker
import {Button} from 'native-base'
when i delete it the error go as well , so i think its kind of conflict between the picker community and native base versions.

Tried to register two views with the same name

Bug

I tried to add the picker, the compilation is fine, but when the app is open appears a red screen with the message:
Tried to register two views with the same name AndroidDropdownPicker

Update: I also use Native base in the project
Can you help me please?

Environment info

React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 696.37 MB / 7.68 GB
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 8.9.0 - ~/.nvm/versions/node/v8.9.0/bin/node
Yarn: 1.15.2 - /usr/bin/yarn
npm: 5.5.1 - ~/.nvm/versions/node/v8.9.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 20, 22, 23, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.1, 25.0.2, 25.0.3, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
IDEs:
Android Studio: 3.4 AI-183.5429.30.34.5452501
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1

React native info output:

 // Tried to register two views with the same name AndroidDropdownPicker

Library version: 0.59.9

Fix example apps

The examples have been copied over from RN core, but they are not yet displayed in the standalone app of this repo.

Picker.Item missing testID

Note: transferred from facebook/react-native#22084

Environment

React Native Environment Info:
System:
  OS: macOS High Sierra 10.13.6
  CPU: x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
  Memory: 82.27 MB / 8.00 GB
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 8.11.3 - /usr/local/bin/node
  npm: 5.6.0 - /usr/local/bin/npm
SDKs:
  iOS SDK:
    Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
IDEs:
  Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
  react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
  react-native: 0.57.4 => 0.57.4
npmGlobalPackages:
  react-native-cli: 2.0.1
  react-native-git-upgrade: 0.2.7

Description

As you can see PickerIOS.Item does not have a testID, even though Picker.Item does.

Picker

type PickerItemProps = $ReadOnly<{|
  /**
   * Text to display for this item.
   */
  label: string,

  /**
   * The value to be passed to picker's `onValueChange` callback when
   * this item is selected. Can be a string or an integer.
   */
  value?: any,

  /**
   * Color of this item's text.
   * @platform android
   */
  color?: ColorValue,

  /**
   * Used to locate the item in end-to-end tests.
   */
  testID?: string,
|}>;

PickerIOS

type ItemProps = $ReadOnly<{|
  label: ?Label,
  value?: ?any,
  color?: ?ColorValue,
|}>;

So I can't find the Items using Detox

itemStyle property not working in android

I want to design individual item in react-native-picker but , the itemStyle property not working:
Here is my code:

<Picker
                    itemStyle = {{fontWeight:"bold",color:"#ff0000"}}
                    selectedValue={language}
                    mode="dropdown"
                    style={{ height: 50, width: 200 }}
                    onValueChange={(itemValue, itemIndex) => { setLanguage(itemValue) } }>
                    <Picker.Item label="Select Area" value="Select Area" />
                    <Picker.Item label="Dhaka" value="Dhaka" />
                    <Picker.Item label="Chittangong" value="Chittangong" />
                    <Picker.Item label="Khulna" value="Khulna" />
                    <Picker.Item label="Rajshahi" value="Rajshahi" />
                </Picker>

Here is my output:

Screenshot_1588846849

Crashes on Android just after build and run without any errors

Hello!

I used the last version with React 16.9.0, RN 0.61.2, and Android 8.1/9 (real device and emulator) and it crashes the app after build and starts. No errors in the console output.

I also tried an older version until 1.1.3 and the issue still happens.

Add new RNCPickerPackage() to the list returned by the getPackages() method

Hello,
I`m new in programming and I have a doubt about installing the Picker package.

It says:
Add new RNCPickerPackage() to the list returned by the getPackages() method

But I have not found the getPackages() method inside the file MainActivity.java

This is my code:

`package com.appname;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import com.reactnativecommunity.picker.RNCPickerPackage;

public class MainActivity extends ReactActivity {

/**

  • Returns the name of the main component registered from JavaScript. This is used to schedule
  • rendering of the component.
    */
    @OverRide
    protected String getMainComponentName() {
    return "appname";
    }

@OverRide
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@OverRide
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
`

So where do I paste it? Thanks! :D

Can't resolve './PickerAndroid', Can't resolve './PickerIOS' in picker/js

i getting error when importing Picker from "@react-native-community/picker". The error say can't resolve PickerAndroid.js and PickerIOS.js in /picker/js. when i checked, yes it's nothing. are u forget to move to js or i wrong with usage way? in docs nobody tell about PickerAndroid.js. Somebody can tell me? thank u

my package.json is
{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/picker": "^1.5.0",
"@react-navigation/bottom-tabs": "^5.4.5",
"@react-navigation/native": "^5.4.0",
"date-fns": "^2.13.0",
"expo": "~37.0.3",
"expo-splash-screen": "^0.2.3",
"expo-updates": "~0.2.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "~0.61.5",
"react-native-gesture-handler": "^1.6.1",
"react-native-reanimated": "^1.8.0",
"react-native-safe-area-context": "^1.0.0",
"react-native-screens": "^2.7.0",
"react-native-timeline-flatlist": "^0.7.2",
"react-native-unimodules": "~0.9.0",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "~7.9.0",
"babel-jest": "~25.2.6",
"jest": "~25.2.6",
"react-test-renderer": "~16.9.0"
},
"jest": {
"preset": "react-native"
},
"private": true
}

Set up data source for Picker to work with Detox

Bug

At the moment, Picker is not working with the setColumnValue() function in Detox due to data source not being set up: https://github.com/react-native-community/react-native-picker/blob/101f272af0e2de57c211f465c81a2c061c72ba4a/ios/RNCPicker.m#L25

This is blocking Detox from getting any values from the Picker and thus we can't automate testing the Picker.

Environment info

    react: ^16.13.1 => 16.13.1 
    react-native: ^0.62.2 => 0.62.2 

This is the ticket opened in Detox with a thorough explanation on the issue: wix/Detox#2031

Change default config please

Can't build release APK because of old build version in build.gradle
Change:
`android {
compileSdkVersion 22
buildToolsVersion 22.0.1

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName 1.0
}
lintOptions {
    abortOnError false
}

}To:android {
compileSdkVersion 28
buildToolsVersion 28.0.3

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName 1.0
}
lintOptions {
    abortOnError false
}

}`

Detox setup

Detox tests are currently turned off. We should add them to improve the coverage and let semantic-release do its work with less worry.

Why so strict? (RN 0.57...0.59)

Question

In peerDependencies it requires react-native up to 0.59 version. Is there any option to adapt it for 0.60+? I can make a PR but I don't really understand is there any known problems with RN version

UI Customization options

Feature Request

There should be options to customize the colour of the down arrow in the dropdown, the background color of the modal which opens up and the font and size of the items.

Why it is needed

It is needed for better customiztions and create better looking dropdowns.

Possible implementation

Add a style option for Item and a modalStyle and arrowColor option for Picker.

Code sample

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

Duplicate Symbols after upgrade to Xcode 11 / react-native 0.60.5

Bug

Receiving the following build error when I try to build my project, now. I updated react-native-picker and react-native and am using XCode 11/ios 13. I have tried to remove the build library linking in XCode, but it keeps getting generated after I run, and I get the same error. Here ist he error:

duplicate symbol '_OBJC_IVAR_$_RCTPicker._selectedIndex' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_IVAR_$_RCTPicker._font' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_IVAR_$_RCTPicker._items' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_IVAR_$_RCTPicker._color' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_CLASS_$_RCTPicker' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_METACLASS_$_RCTPicker' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_IVAR_$_RCTPicker._textAlign' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_IVAR_$_RCTPicker._onChange' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPicker.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPicker.o)
duplicate symbol '_OBJC_CLASS_$_RCTPickerManager' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPickerManager.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPickerManager.o)
duplicate symbol '_OBJC_METACLASS_$_RCTPickerManager' in:
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTPickerManager.o)
    /Users/shawnadonnelly/Documents/GitHub/RN-PartnerPay/ios/build/PartnerPay/Build/Products/Debug-iphonesimulator/react-native-picker/libreact-native-picker.a(RCTPickerManager.o)
ld: 10 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Environment info

React native info output:

System:
    OS: macOS Mojave 10.14.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 35.44 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 23, 26, 28
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.6 => 0.60.6 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Library version: 1.1.1

Steps To Reproduce

react-native run-ios --simulator "iPhone 11 Pro";

...

Describe what you expected to happen:

  1. Build

Reproducible sample code

AndroidX support

currently I had to apply this hack to get the package to work. As androidx is now standard for react native, this package should support it as well.

Android example doesn't run

Bug

Environment info

React native info output:

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
      Memory: 13.63 GB / 31.79 GB
    Binaries:
      Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD

Library version: master branch

Steps To Reproduce

  1. Clone repo
  2. yarn install
  3. cd example & yarn start
  4. open example/android with Android Studio and run test app

Undefined is not an object (evaluating '_js.PickerIOS.Item)
image

Describe what you expected to happen:
Sample app should run without issue.

Can't place the Picker on beside text when 'flexDirection' is row.

My example code:

...
  render() {
    return (
      <View style={styles.container}>
        <Text>Height</Text>
        <Text style={styles.result_text}>170</Text>
        <Picker
          selectedValue={this.state.unit}
          style={{height: 50, width: 100}}
          itemStyle={{textAlign: 'left', fontSize: 14}}
          onValueChange={(itemValue, itemIndex) =>
            this.setState({unit: itemValue})
          }>
          <Picker.Item label="cm" value="cm" />
          <Picker.Item label="feet, inches" value="feet" />
        </Picker>
      </View>
    );
...
const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    alignItems: 'center',
  },
}
  • Screenshot
    image

Want to add custom button for picker to show options

Question

I want to remove the dropdown button and use my own for styling, can you please let me know the following:
1- How to hide the existing dropdown button (one hack is to put some bg color over it to hide but proper method would be appreciated)
2- What event / callback does that dropdown button fire so that I can use the same event for it

Thanks

TypeError: Cannot read property 'target' of undefined

Bug report

Summary

Environment info

react-native info output:

❯ react-native info
info Fetching system and libraries information...
(node:36508) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
System:
    OS: macOS 10.15.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 354.84 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
  IDEs:
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  npmPackages:
    react: ~16.9.0 => 16.9.0
    react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4
  npmGlobalPackages:
    react-native-cli: 2.0.1

Library version: 1.6.3

Steps to reproduce

  1. expo init picker-issue (choose blank typescript template)
  2. cd picker-issue
  3. yarn add @react-native-community/picker
// App.tsx

import React from "react";
import { Picker } from "@react-native-community/picker";
import { ItemValue } from "@react-native-community/picker/typings/Picker";

export default function App() {
    const [value, setValue] = React.useState<ItemValue>("key1");
    return (
        <Picker
            testID="basic-picker"
            selectedValue={value}
            onValueChange={v => setValue(v)}
        >
            <Picker.Item label="hello" value="key0" />
            <Picker.Item label="world" value="key1" />
        </Picker>
    );
}
  1. expo start

I get the following error:

TypeError: Cannot read property 'target' of undefined
(anonymous function)
node_modules/@react-native-community/picker/js/Picker.web.js:48
  45 | const hostRef = useRef(null);
  46 | 
  47 | const handleChange = React.useMemo<any>(
> 48 |   (e: Object) => {
     | ^  49 |     const {selectedIndex, value} = e.target;
  50 |     if (onValueChange) {
  51 |       onValueChange(value, selectedIndex);

initializing picker in "dropdown" mode on android triggers onValueChange

Bug

we are trying to attach some additional action to onValueChange like focusing a TextInputField. Unfortunately this gets triggered as soon as the page loads. IMO this shouldn't happen.

Environment info

Languages:
Java: 1.8.0_45 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0

Binaries:
Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
Yarn: 1.22.0 - ~/.yarn/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v13.9.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman

SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 19, 21, 23, 24, 25, 26, 27, 28
Build Tools: 19.1.0, 21.1.2, 23.0.1, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
System Images: a...google_apis | Google APIs Intel x86 Atom Sys..., a... | Intel x86 Atom_64, a...google_apis | Google APIs Intel x86 Atom Sys..., a...gle_apis | Google APIs Intel x86 Atom_64 ..., a...google_apis | Google APIs Intel x86 Atom Sys...
Android NDK: Not Found

Steps To Reproduce

  1. init the Picker e.g. like so:
    import { Picker } from '@react-native-community/picker';
    ...
    <Picker selectedValue={this.props.selectedValue} onValueChange={this.androidOnValueChange} mode="dropdown" style={{ width: this.props.widthAndroid }}>
      {this.props.options.map((i) => (
        <Picker.Item label={i.toString()} value={i.toString()} key={i} />
      ))}
    </Picker>
  1. observe the initial call.

If this is wont-fix, can you maybe provide a workaround? I only came up with ugly timeout based hacks until now.

onValueChange not called on android when there is only one option

Bug

On android, with a Picker with only one available option and a selectedValue of null, pressing the option to select it doesn't trigger onValueChange.

Environment info

React native info output:

 System:
    OS: macOS 10.15.2
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 134.31 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.10.0 - ~/.nvm/versions/node/v12.10.0/bin/node
    npm: 6.13.7 - ~/Documents/teamworks/ui/mobile/node_modules/.bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.12.0 => 16.12.0 
    react-native: 0.61.5 => 0.61.5

Library version: 1.3.0

Steps To Reproduce

  1. On android, render a component with no selectedValue and one <Picker.Item> child.
  2. Open the dialog and press on the item
  3. The dialog closes but the onValueChange callback is not called

Describe what you expected to happen:

  1. I expected onValueChange to be called.

Reproducible sample code

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

const PickerExample = () => (
  <Picker
    onValueChange={(value, index) => { console.log(value, index); }}
  >
    <Picker.Item key="option-1-key" value="option-1" label="option 1" />
  </Picker>
);

Picker component does not have an onTouch property

Bug

Description:

The current picker does not have any event listeners for onBlur, onTouch events. So it is impossible in the app to know if the user has interacted with the picker component. The only way to know if a user has made contact with the component is through the onValueChange property. However, if the user opens the picker on Android, but doesn't select a value and/or closes the picker, the app cannot know if the user has interacted with the picker.

This is needed for form validations, to display warnings or error messages after the user has "touched" the picker component.

Environment info

System:
OS: macOS 10.15.3
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 6.30 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.1 - /usr/local/bin/node
npm: 6.13.4 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native: 0.61.5

Steps To Reproduce

  1. Import Picker component from react-native library,
  2. Check the props of Picker component.

Expected Results

There should be a listener event of touch gestures or focus changes.

Can't install lib as dependency

Bug

Command npm install @react-native-community/picker --save or yarn add @react-native-community/picker return 404.

Error log:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@react-native-community%2fpicker - Not found
npm ERR! 404 
npm ERR! 404  '@react-native-community/picker@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:

Environment info

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
      Memory: 367.23 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.14.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2/10E125 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2

Steps To Reproduce

Run above commands in terminal

Describe what you expected to happen:

Install dependencies properly

Can't update selectedValue outside of Picker

Bug

Environment info

react-native: 0.60.5
Android 9

react-native info output:
OS macOS Mojave 10.14.6
Node13.8.0
Npm 6.13.7

Steps To Reproduce

Create empty project with Picker and some button(timeout) that should change selectedValue

Describe what you expected to happen:

selectedValue is changed

Reproducible sample code

Some code pasted here(to run switch to android) https://snack.expo.io/BkB184II8

React.createElement: type is invalid

Bug

When using this library on iOS, I get a warning:

ExceptionsManager.js:94 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at PickerAndroid.ios.js:15.

The problem is there never will be a PickerAndroid for iOS. Why is there a PickerAndroid.ios.js file at all? Wouldn't the traditional way be having one Picker.ios.js (for PickerIOS) and Picker.android.js (for PickerAndroid)?

I know the message is pretty much harmless, it just seems to be poor design to ALWAYS have a warning message for normal use of a library.

Environment info

React native info output:

info Fetching system and libraries information...
System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
    Memory: 17.90 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.0 - /usr/local/bin/node
    Yarn: 1.12.3 - ~/.yarn/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 28
      Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.6 => 0.60.6 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-debugger-open: 0.3.11
    react-native-git-upgrade: 0.2.7
    react-native-rename: 2.1.5

Library version: 1.1.2

Steps To Reproduce

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

Describe what you expected to happen:

  1. Not receiving this warning message

Reproducible sample code

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

[web] createElement is not a function

Bug report

Summary

trying to use the Picker element with react-native-web version 0.12+ results in error createElement is not a function

This is because in react-native-web 0.12+, createElement is renamed to unstable_createElement

Since expo is using react-native-web v0.11, which still has createElement exported, it would be nice if there is a way for both expo-web users and react-native-web users to be able to use the picker component without any issues.

Environment info

Library version:
react-native-web: 0.12.2

Steps to reproduce

  1. Use Picker component in web

Describe what you expected to happen:

  1. expect Picker to work in both expo-web and react-native-web projects

Reproducible sample code

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

type Props = {};
export const YearMonthPicker: React.FC<Props> = () => {
  return (
    <Picker selectedValue={'test'}>
      <Picker.Item value={'test'}>Test</Picker.Item>
    </Picker>
  );
};

Picker Android "dialog" not applicable

Bug

When using picker in android, changing mode to 'dialog' is never being applied.
Always working as 'dropdown' not 'dialog',

Environment info

picker version: 1.1.1

React native info output:

System:
    OS: macOS 10.15
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 242.88 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 28.0.3, 29.0.0, 29.0.1
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.4 => 0.60.4
  npmGlobalPackages:
    create-react-native-app: 2.0.2
    react-native-cli: 2.0.1

Library version: 1.1.1

Steps To Reproduce

  1. Install Picker
  2. add dialog mode
    ...

Describe what you expected to happen:

  1. when change mode to 'dialog', I expect modal open for picker selection

Reproducible sample code

My code:

 <Picker
              selectedValue={this.state.type}
              style={{
                width: 100,
                color: "#fff"
              }}
              prompt="오전/오후"
              mode="dialog"
              itemStyle={{
                color: "white"
              }}
              // style={{ height: 50, width: 100 }}
              onValueChange={(itemValue, itemIndex) =>
                this.setState({ type: itemValue })
              }
            >
              <Picker.Item label="오후" value="night" />
              <Picker.Item label="오전" value="dawn" />
            </Picker>

SyntaxError: Unexpected token export when running jest

Bug report

Summary

When I run the test I get this error:

   Details:
    /****/****/****/***/*****/node_modules/@react-native-community/picker/js/index.js:5
    export {default as Picker} from './Picker';
    ^^^^^^
    SyntaxError: Unexpected token export

Environment info

react-native info output:

  React Native Environment Info:
    System:
      OS: Linux 5.3 Ubuntu 18.04.4 LTS (Bionic Beaver)
      CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
      Memory: 542.64 MB / 15.55 GB
      Shell: 5.4.2 - /usr/bin/zsh
    Binaries:
      Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node
      Yarn: 1.21.1 - /usr/bin/yarn
      npm: 6.13.7 - ~/.nvm/versions/node/v12.4.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 23, 24, 26, 27, 28, 29
        Build Tools: 26.0.0, 27.0.3, 28.0.3, 29.0.0, 29.0.1, 29.0.2
        System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.10 => 0.59.10 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7
      react-native-rename: 2.4.1

Library version: 1.6.1

Steps to reproduce

  1. just run npm test

Webpack compatibility issue

Bug report

Summary

The module is not compatible with webpack due to mix of imports and module.exports in several files: 1, 2. Which makes it unusable with default configuration of haul.

Environment info

react-native info output:

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 72.88 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.15.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.6 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ~16.11.0 => 16.11.0 
    react-native: ^0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 1.5.1

Steps to reproduce

  1. Replace metro bundler with haul
  2. Try to launch the app

Describe what you expected to happen:

  1. The app launches, picker is functional

Actual result:

Unhandled JS Exception: Attempted to assign to readonly property.

http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:10156:7
./node_modules/.pnpm/registry.npmjs.org/@react-native-community/picker/1.5.1_686ec919160581136b28b7fe63160a42/node_modules/@react-native-community/picker/js/RNCPickerNativeComponent.js@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:10157:34
__webpack_require__@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:20:34
./index.js@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:8777:51
__webpack_require__@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:20:34
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:179923:37
__webpack_require__@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:20:34
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:84:37
global code@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:85:12

Probem while importing the Community Picker

Bug report

Summary

Environment info

react-native info output:

# The project name ' @react-native-community/picker' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.