react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.44k stars 273 forks source link

'Picker' cannot be used as a JSX component. #171

Closed reggi closed 3 years ago

reggi commented 3 years ago

I am getting this typescirpt error :(

kolobashek commented 3 years ago

Same error. What did you do?

connorlindsey commented 2 years ago

Same error here with Typescript

erdemgonul commented 2 years ago

After wasting hours, I found the solution. Just add that into your package.json

"resolutions": {
  "@types/react": "17.0.2",
  "@types/react-dom": "17.0.2"
},

Credits: https://stackoverflow.com/a/71828113/8198997

IAmCoder commented 2 months ago

Instead of importing like this:

import Picker from '@react-native-picker/picker

Change the import to:

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

Without the curly braces it expects Picker to be the default export: https://stackoverflow.com/a/36796281/4279006.