未定义不是对象(评估'React.PropTypes.Number')错误

时间:2018-02-12 16:55:01

标签: javascript json reactjs react-native expo

刚刚从expo 21.0.0更新为22.0.0,我收到此错误:

enter image description here

这是我的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。有任何想法吗?

2 个答案:

答案 0 :(得分:1)

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

安装prop-types

npm install prop-types --save

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

import PropTypes from 'prop-types';

答案 1 :(得分:0)

检查npm模块中所有模块的JS文件

"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"

替换

import {PropTypes} from 'react';

使用

import PropTypes from 'prop-types';

每个文件中