简体   繁体   English

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

[英]Picker has been removed from React Native. It can now be installed and imported from '@react-native-picker/picker'

PLEASE HELP:!I have search the entire project which DOES NOT use Pricker at all but when I run npx react-native run-android it throws out :请帮助:!我已经搜索了整个项目,它根本不使用 Picker,但是当我运行 npx react-native run-android 它抛出:

ERROR Invariant Violation: Picker has been removed from React Native. ERROR Invariant Violation: Picker 已从 React Native 中移除。 It can now be installed and imported from '@react-native-picker/picker' instead of 'react-native'.现在可以从“@react-native-picker/picker”而不是“react-native”安装和导入它。 See https://github.com/react-native-picker/picker ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).请参阅https://github.com/react-native-picker/picker错误不变违规:模块 AppRegistry 不是已注册的可调用模块(调用 runApplication)。 A frequent cause of the error is that the application entry file path is incorrect.错误的常见原因是应用程序入口文件路径不正确。 This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.当 JS 包损坏或加载 React Native 时出现早期初始化错误时,也会发生这种情况。

Same problem faced by this guy at the below link...No answer available... Please help...Thank you in advance这个人在下面的链接中面临同样的问题......没有答案......请帮助......提前谢谢你

Invariant Violation: Picker has been removed from React Native Invariant Violation:Picker 已从 React Native 中移除

I have @react-native-picker/picker installed我安装了@react-native-picker/picker

This is my package.json这是我的 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)"

Officially picker has been removed from react-native.官方选择器已从 react-native 中删除。 You can use the community edition.您可以使用社区版。 @react-native-community/picker @react-native-community/picker

Delete node modules folder then run yarn install at the terminal in your projects directory.删除节点模块文件夹,然后在项目目录的终端上运行yarn install

Then try to run the app again.然后尝试再次运行该应用程序。

I am not sure this will help but since it says This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.我不确定这会有所帮助,但因为它说当 JS 包损坏或加载 React Native 时出现早期初始化错误时也会发生这种情况。 it might be worth trying.这可能值得一试。

  1. Install @react-native-picker/picker安装@react-native-picker/picker
  2. Upgrade "native-base": "2.15.2"升级"native-base": "2.15.2"

In my case, tcomb-form-native caused this error because it has not been updated for years.就我而言, tcomb-form-native导致了这个错误,因为它已经多年没有更新了。 I hope this PR will be merged soon.我希望这个 PR 将很快被合并。 https://github.com/gcanti/tcomb-form-native/pull/605 https://github.com/gcanti/tcomb-form-native/pull/605

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM