React-native-picker-select: Tried to register two views with the same name AndroidDropdownPicker

Created on 4 May 2020  路  14Comments  路  Source: lawnstarter/react-native-picker-select


Describe the bug

Getting error with following message:

Tried to register two views with the same name AndroidDropdownPicker

The error seems to be similar to this:
https://github.com/react-native-community/react-native-picker/issues/15

To Reproduce

Steps to reproduce the behavior:
In my project, I have used also this component:
import { Picker } from '@react-native-community/picker';
I believe it is a clash between these components. Any way to avoid this error and be able to use both?

Expected behavior

Be able to use this component without clashing with other components.

Screenshots

"n/a".

Additional details

  • Device: Android
  • OS: Android 10
  • react-native-picker-select version: 7.0.0
  • react-native version: 0.62.2
  • react version: 16.11.0

Reproduction and/or code sample

import React, { useState } from 'react';
import { StyleSheet, TouchableNativeFeedback, View, Text, Image } from 'react-native';
import RNPickerSelect from 'react-native-picker-select';

export default function AdminHome({ navigation }) {
    return (
            <View>
                <RNPickerSelect
                accessibilityLabel={'gender'}
                    onValueChange={(value) => console.log(value)}
                    items={[
                        { label: 'Football', value: 'football' },
                        { label: 'Baseball', value: 'baseball' },
                        { label: 'Hockey', value: 'hockey' },
                    ]}
                />
        </View>
    );
}


duplicate

Most helpful comment

@react-native-community/picker deprecated. So remove it by yarn remove @react-native-community/picker and install yarn add @react-native-picker/picker . This solved the issue for me.

All 14 comments

Also, the solution mentioned here did not work for me. All my imports of that component already were:
import { Picker } from '@react-native-community/picker';

+1

I have also faced the same issue
Screenshot from 2020-05-19 12-45-33

+1

I have also faced the same issue
Screenshot from 2020-05-19 12-45-33

These are the libraries version im using
"@react-native-community/picker": "^1.5.0",
"react": "16.9.0",
"react-native": "0.61.2",

sounds like the issue is using both this library and the newly abstracted Picker library.

either that library will need to be updated to handle this scenario - or this'll be solved once #303 is merged in.

i have the same issue

Can confirm #303 solves this.

For now you can use patch-package to switch this package to the community library.

Any idea when this will be merged?

I know this has been closed. 8.0.1 Fixed my iOS issues but it started breaking my Android build.

@plgrazon worth opening a new report

Build is failing for android

@plgrazon worth opening a new report

Yup! Just did issue #374

I fixed this problema installing the following versions:
"@react-native-community/picker": "1.6.0"
"react-native-picker-select": "7",

@react-native-community/picker deprecated. So remove it by yarn remove @react-native-community/picker and install yarn add @react-native-picker/picker . This solved the issue for me.

I changed react-native-community/datetimepicker version from

2.4.0 to 3.0.9

"@react-native-community/datetimepicker": "^3.0.9"

We can assume the old version will get error

Was this page helpful?
0 / 5 - 0 ratings