Undefined is not an object (evalating 'React.PropTypes.Number') 错误 [英] Undefined is not an object (evaluating 'React.PropTypes.Number') error

查看:24
本文介绍了Undefined is not an object (evalating 'React.PropTypes.Number') 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚从 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';

这篇关于Undefined is not an object (evalating 'React.PropTypes.Number') 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆