react-native-picker
react-native-picker copied to clipboard
Error: Invariant Violation: Element type is invalid: expected a string
"react-native": "0.52.0" "react-native-picker": "^4.3.5"
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of PickerTest
.
This error is located at: in RCTView (at View.js:71) in View (at PickerTest.js:52) in PickerTest (at renderApplication.js:35) in RCTView (at View.js:71) in View (at AppContainer.js:102) in RCTView (at View.js:71) in View (at AppContainer.js:122) in AppContainer (at renderApplication.js:34)
import React, {Component} from 'react';
import {
View,
Text,
TouchableOpacity,
Dimensions
} from 'react-native';
import Picker from 'react-native-picker';
function createDateData(){
let date = {};
for(let i=1950;i<2050;i++){
let month = {};
for(let j = 1;j<13;j++){
let day = [];
if(j === 2){
for(let k=1;k<29;k++){
day.push(k);
}
}
else if(j in {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1}){
for(let k=1;k<32;k++){
day.push(k);
}
}
else{
for(let k=1;k<31;k++){
day.push(k);
}
}
month[j] = day;
}
date[i] = month;
}
return date;
};
export default class PickerTest extends Component {
constructor(props){
super(props);
}
_onPressHandle(){
this.picker.toggle();
}
render(){
return (
<View style={{height: Dimensions.get('window').height}}>
<TouchableOpacity style={{marginTop: 20}} onPress={this._onPressHandle.bind(this)}>
<Text>Test</Text>
</TouchableOpacity>
<Picker
ref={picker => this.picker = picker}
style={{height: 320}}
showDuration={300}
pickerData={createDateData()}
onPickerDone={(pickedValue) => {
console.log(pickedValue);
}}
/>
</View>
);
}
};
Kindly let me know to solve the issue
Any update here? Is this library useable anymore? I have an expo app, and it does not seem to support this library.
Looks like pure javascript version is not supported by the author. Hence <Picker....> is not supported in latest RN versions. https://github.com/beefe/react-native-picker/tree/pure-javascript-version
I have switched to Picker.init({....}).
@ugendrang Is work in pure javascript version that you use Picker.init ?
Is still library working ? it's seems not working in android but I haven't checked in iOS?
I've got this problem...someone help please @marcusegues @ugendrang @weishai @Nics08 @jayeeliu
@kilobyteforce what kind of issue are you facing?
I have the same question,Who can support a solution.
Looks like pure javascript version is not supported by the author. Hence <Picker....> is not supported in latest RN versions. https://github.com/beefe/react-native-picker/tree/pure-javascript-version
I have switched to Picker.init({....}).
I just want to change the picker position,not just bottom.