Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid hook call when using Picker on Android #424

Open
MandoMG opened this issue Jun 21, 2022 · 6 comments
Open

Invalid hook call when using Picker on Android #424

MandoMG opened this issue Jun 21, 2022 · 6 comments

Comments

@MandoMG
Copy link

MandoMG commented Jun 21, 2022

I implemented the picker on iOS but on Android I'm getting an Invalid hook call everytime I reach the component where my picker lives. Is anyone else seeing this issue?

image

const ItemPicker = (props: ItemPickerProps) => {
 return (
    <View>
      <Picker
          selectedValue={selectedItem}
          onValueChange={(itemValue, itemIndex) =>
            setSelectedItem(itemValue)
          }>
          <Picker.Item label="Java" value="java" />
          <Picker.Item label="JavaScript" value="js" />
        </Picker>
    </View>
  )
};

export default ItemPicker;

"react": "17.0.2",
"react-native": "0.67.1",
"@react-native-picker/picker": "^2.4.1"

@erez-unitronics
Copy link

erez-unitronics commented Jul 28, 2022

+1
"react": "18.0.0",
"react-native": "0.69.3"
"@react-native-picker/picker": "^2.4.2"

@Nesh108
Copy link

Nesh108 commented Sep 6, 2022

Same here!

"react": "18.2.0",
"react-native": "0.69.5",
"@react-native-picker/picker": "^1.8.3",

@frabanca
Copy link

As reported by @stocaaro here, it seems to be an issue related to ReactNative >= 0.69.

There are 3 workarounds:

  1. Use --legacy-peer-deps when installing picker npm install @react-native-picker/picker --legacy-peer-deps (worked for me)
  2. Use an older version of react-native npx [email protected] init $PROJECTNAME --version 0.68.0
  3. Use a package manager that doesn't enforce peer dependencies such as yarn or npm prior to 7

@farmstrong8
Copy link

bump

@nlarif
Copy link

nlarif commented Dec 14, 2022

Same here with :

"react": "18.0.0"
"react-native": "0.69.6"
 "@react-native-picker/picker": "2.4.3"

@nlarif
Copy link

nlarif commented Dec 16, 2022

Solved for me.
I am using react-native-picker-select on top of @react-native-picker/picker. I found out that react-native-picker-select was installing on old version of @react-native-picker/picker under node_modules/react-native-picker-select/node_modules/@react-native-picker/picker which was the one throwing the exception.
I updated my packages.json with:

"resolutions": {
   "react-native-picker-select/@react-native-picker/picker": "^2.4.8"
 },

and used Yarn locally and in my CI/CD. I removed the usage of npm install --save --legacy-peer-deps which is no longer needed.
Now react-native-picker-select is relying on the newest version within node_modules and I don't see the error anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants