Skip to content

Invalid Hook Call, inside react-native-picker-select #486

@emilseuor

Description

@emilseuor

Invalid Hook Call error inside react-native-picker-select node module.

Describe the bug

I get this issue everytime I build in android, it would show "Invalid Hook Call error" when it has to render the screen that uses RNPickerSelect (react-native-picker-select)

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

This error is located at:
in PickerAndroid (at Picker.js:174)
in Picker (at src/index.js:491)
in RCTView (at View.js:32)
in View (at src/index.js:489)
in RCTView (at View.js:32)
in View (at createAnimatedComponent.js:211)
in AnimatedComponent (at createAnimatedComponent.js:264)
in AnimatedComponentWrapper (at TouchableOpacity.js:224)
in TouchableOpacity (at TouchableOpacity.js:280)
in TouchableOpacity (at src/index.js:483)
in RNPickerSelect (at Picker.tsx:39)
in RCTView (at View.js:32)
in View (at Picker.tsx:38)
in RCTView (at View.js:32)
in View (at Picker.tsx:36)

To Reproduce

Steps to reproduce the behavior:

  1. Add react-native-picker-select on a react native app (react-native init Test)
  2. Add RNPickerSelect useNativeAndroidPickerStyle={false} in a screen with data
  3. Build in android (react-native run-android)
  4. See error

Expected behavior

It would render the picker and not crash the app

Screenshots

image
image

Additional details

  • Device: Android 11G Emulator
  • OS: Android 11
  • react-native-picker-select version: ^8.0.4
  • react-native version: ^0.68.5
  • expo sdk version: n/a

Reproduction and/or code sample

<RNPickerSelect
placeholder={{label: 'test', value: 'test'}}
items={items}
onValueChange={props.functionOnChange}
style={styles}
useNativeAndroidPickerStyle={false}
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions