react-native-picker / picker

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

Warning: React.createElement: type is invalid #350

Open ZainaliSyed opened 3 years ago

ZainaliSyed commented 3 years ago

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.

Environment info

"@react-native-picker/picker": "^2.2.0", "react": "17.0.2", "react-native": "0.66.1",

ISSUE

I am facing this warning issue in Chrome Debugging Whenever I comment this Picker.item warning vanish there is something wrong inside it

CODE

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

<Picker
style={this.styles.picker}
selectedValue={data.LadderModel}
onValueChange={(itemValue) => {
this.changeLadderModel(itemValue, data_id);
}}

<Picker.item label="Model 3" value="3" />
<Picker.item label="Model 4" value="4" />
<Picker.item label="Model 5" value="5" />
<Picker.item label="Other" value="other" />
ArkaneKhan commented 3 years ago

facing same issue.

kei95 commented 3 years ago

@ZainaliSyed Apparently, the Picker class has a static value Item rather than item. I tried with item in my local env and had the same warning but could solve it by replacing the value with Item. I think it's worth giving it a shot.

I also confirmed that read.me file's example is using Item so that should be the "official" value. I hope that helps. Usage: https://github.com/react-native-picker/picker#usage

albinr3 commented 2 years ago

Your problem is you are writing Picker.item instead of Picker.Item (i must be uppercase)