react-native-picker icon indicating copy to clipboard operation
react-native-picker copied to clipboard

Error: Invariant Violation: Element type is invalid: expected a string

Open ugendrang opened this issue 7 years ago • 8 comments

"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

ugendrang avatar Jan 30 '18 16:01 ugendrang

Any update here? Is this library useable anymore? I have an expo app, and it does not seem to support this library.

marcusegues avatar Mar 13 '18 10:03 marcusegues

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 avatar Mar 16 '18 03:03 ugendrang

@ugendrang Is work in pure javascript version that you use Picker.init ?

weishai avatar Mar 17 '18 13:03 weishai

Is still library working ? it's seems not working in android but I haven't checked in iOS?

Nics08 avatar May 29 '18 13:05 Nics08

I've got this problem...someone help please @marcusegues @ugendrang @weishai @Nics08 @jayeeliu

kilobyteforce avatar Dec 22 '18 06:12 kilobyteforce

@kilobyteforce what kind of issue are you facing?

Nics08 avatar Dec 23 '18 07:12 Nics08

I have the same question,Who can support a solution.

zuijiusi avatar Dec 20 '19 03:12 zuijiusi

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.

zuijiusi avatar Dec 20 '19 03:12 zuijiusi