React-native:Undefined is not an object
Undefined is not an object(evaulating PropTypes.arrayOf)Undefined is not an object(evaulating PropTypes.func)undefined is not an object evaluating ReactInternals.ReactCurrentOwner针对这样的报错,如果排除拼写错误,则
Undefined is not an object(evaulating PropTypes.arrayOf)
Undefined is not an object(evaulating PropTypes.func)
undefined is not an object evaluating ReactInternals.ReactCurrentOwner
针对这样的报错,如果排除拼写错误,则基本是ReactNative版本问题。
解决办法:升级或降级React-Native 版本
方法1:
查看react-native 历史版本信息
npm info react-native;
升级
npm install –save react-native@x.x.x(x.x.x版本号)
react-native –save react@x.x.x(x.x.x版本号)
方法2:
删除nodemodules目录;
修改package.json:
"react": "^16.0.0",
"react-native": "^0.50.4"
这里是升级到最新版本。
执行npm install命令。
对于 Undefined is not an object(evaulating PropTypes.arrayOf)
Undefined is not an object(evaulating PropTypes.func)
这样的报错,PropTypes未识别。是由于React 在15.5版本将PropTypes独立出来,作为一个单独的module。
这样的错误还需要安装PropTypes 包,并改变PropTypes的引入方式:
安装PropTypes
npm install --save prop-types
对PropTypes的引用方式进行修改
import {PropTypes} from 'prop-types';//es6
var PropTypes=require('prop-types');//es5
以上两种方式,只需使用一种。
脚本自动修改,待续。
更多推荐
所有评论(0)