Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] The picker component encountered an error and cannot be used #583

Open
xxwangkaimin opened this issue Sep 19, 2024 · 0 comments
Open

Comments

@xxwangkaimin
Copy link

The contents of the package.json file are as follows:

{
  "name": "awesome-project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-picker/picker": "^2.8.0",
    "react": "18.3.1",
    "react-native": "0.75.1",
    "react-native-webview": "^13.12.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.75.1",
    "@react-native/eslint-config": "0.75.1",
    "@react-native/metro-config": "0.75.1",
    "@react-native/typescript-config": "0.75.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

windows version: windows 10
nodejs version: 18.18.0
The code content is as follows:

import React, {useState} from 'react'
import {Text, View} from 'react-native'
import {Picker} from '@react-native-picker/picker'

function PickerDemo(): React.JSX.Element {
  const [selectedLanguage, setSelectedLanguage] = useState()
  return (
    <View>
      <Text>Picker</Text>
      <Picker
        selectedValue={selectedLanguage}
        onValueChange={(itemValue) =>
          setSelectedLanguage(itemValue)
        }>
        <Picker.Item label="Java" value="java" />
        <Picker.Item label="JavaScript" value="js" />
      </Picker>
    </View>
  )
}

export default PickerDemo

The error message during operation is as follows:
image
The simulator error message is as follows:
Screenshot_20240919_111432
If the picker component is not used, it is normal:
Screenshot_20240919_111711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant