picker
picker copied to clipboard
Warning: React.createElement: type is invalid
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
<Picker.item label="Model 3" value="3" />
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" />
facing same issue.
@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
Your problem is you are writing Picker.item instead of Picker.Item (i must be uppercase)