Picker 已从 React Native 中删除。现在可以从“@react-native-picker/picker”安装和导入它

run*_*366 8 javascript android react-native

请帮忙!!我已经搜索了整个项目,它根本不使用Pricker,但是当我运行 npx react-native run-android 时,它会抛出:

错误不变违规:Picker 已从 React Native 中删除。现在可以从“@react-native-picker/picker”而不是“react-native”安装和导入它。请参阅 https://github.com/react-native-picker/picker错误不变违规:模块 AppRegistry 不是已注册的可调用模块(调用 runApplication)。导致该错误的常见原因是应用程序入口文件路径不正确。当 JS 包损坏或加载 React Native 时出现早期初始化错误时,也可能会发生这种情况。

这个人在下面的链接中面临同样的问题...没有可用的答案...请帮助...提前谢谢您

违反不变性:Picker 已从 React Native 中删除

我安装了 @react-native-picker/picker

这是我的 package.json

  "name": "MYAPP",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "build-android": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.android.js --bundle-output iOS/main.jsbundle --platform 'android' --assets-dest ./  --dev false --reset-cache",
    "test": "jest",
    "test:watch": "npm run test -- --watch",
    "postinstall": "npx jetify",
    "extractLangs": "react-gettext-parser --output messages.pot 'src/**/*.js'"
  },

  "dependencies": {
    "@react-native-community/cli": "^6.3.1",
    "@react-native-community/masked-view": "0.1.11",
    "@react-native-picker/picker": "^2.2.1",
    "axios": "0.24.0",
    "base-64": "1.0.0",
    "date-fns": "2.27.0",
    "gettext.js": "git+https://github.com/freiserg/gettext.js.git",
    "lodash": "4.17.21",
    "react": "17.0.2",
    "react-native": "0.66.3",
    "react-native-device-info": "8.4.8",
    "react-native-eject": "0.1.2",
    "react-native-extended-stylesheet": "0.12.0",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "^2.1.0",
    "react-native-keyboard-aware-scroll-view": "0.9.5",
    "react-native-navigation": "7.24.2",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-splash-screen": "3.3.0",
    "react-native-swipeout": "2.3.6",
    "react-native-swiper": "1.6.0",
    "react-native-vector-icons": "9.0.0",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "7.2.6",
    "redux": "4.1.2",
    "redux-logger": "3.0.6",
    "redux-persist": "6.0.0",
    "redux-thunk": "2.4.1",
    "shitty-qs": "1.0.1",
    "tcomb-form-native": "0.6.20"
  },
  "devDependencies": {
    "babel-eslint": "10.0.1",
    "babel-jest": "27.4.5",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.6",
    "eslint": "8.4.1",
    "eslint-config-airbnb": "19.0.2",
    "eslint-plugin-import": "2.25.3",
    "eslint-plugin-jsx-a11y": "6.5.1",
    "eslint-plugin-react": "7.27.1",
    "jest": "27.4.5",
    "jetifier": "2.0.0",
    "metro-react-native-babel-preset": "^0.66.2",
    "nock": "13.2.1",
    "react-gettext-parser": "1.16.0",
    "react-native-mock": "0.3.1",
    "react-test-renderer": "17.0.2",
    "redux-mock-store": "1.5.4"
  },
  "jest": {
    "preset": "react-native",
    "verbose": true,
    "setupFiles": [
      "<rootDir>/__tests__/mocks/global.js"
    ],
    "testMatch": [
      "**/__tests__/**/*.spec.js?(x)"
Run Code Online (Sandbox Code Playgroud)

小智 0

官方选择器已从 React-Native 中删除。您可以使用社区版。@react-native-community/picker