Undefined is not an object (evalating 'React.PropTypes.Number') 错误

2022-01-23 00:00:00 json reactjs javascript react-native expo

刚刚从 expo 21.0.0 更新到 22.0.0 我收到了这个错误:

Just updated from expo 21.0.0 to 22.0.0 and I am getting this error:

这是我的 package.json:

this is my package.json:

{
  "name": "APP",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.5.0",
    "jest-expo": "^22.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^22.0.0",
    "react": "16.0.0-beta.5",
    "react-native": "https://github.com/expo/react-native/archive/sdk-22.0.1.tar.gz",
    "react-native-autocomplete-input": "3.3.1",
    "react-native-check-box": "2.0.0",
    "react-native-easy-toast": "1.0.9",
    "react-native-elements": "0.13.0",
    "react-native-global-props": "1.1.1",
    "react-native-htmlview": "0.12.1",
    "react-native-modal-dropdown": "0.5.0",
    "react-native-modalbox": "1.4.2",
    "react-native-parallax-scroll-view": "0.20.1",
    "react-native-tag-input": "0.0.14",
    "react-native-vector-icons": "4.2.0",
    "react-navigation": "^1.0.0-beta.27"
  },
  "rnpm": {
    "assets": [
      "./src/assets/fonts/"
    ]
  }
}

很难弄清楚为什么更新会搞砸应用.很可能它是一个 proptypes 更新的东西,我目前没有在应用程序中使用任何 proptypes.有任何想法吗?

Having hard time figuring out why updating messed up the app. Most likely it is a proptypes update thing, I am currently not using any proptypes in the app. Any ideas?

推荐答案

PropTypes 已从 react 中移除,因此您需要安装 prop-types 并从中导入:

PropTypes is removed from react so you need to install prop-types and import it from that:

安装prop-types:

npm install prop-types --save

从 prop-type 导入 PropTypes 而不是从 react 导入 PropTypes:

Import PropTypes from prop-type instead of import PropTypes from react:

import PropTypes from 'prop-types';

相关文章