安装反应原生md-textinput后,当我尝试启动应用程序时出现以下错误。Undefined不是一个对象(评估'React.PropTypes.Number'(下划线.js
下面是我的包.json
"反应": "16.0.0","反应原生": "^0.49.5","react-native-md-textinput": "^2.0.4","反应导航": "^1.0.0-beta.19">
尝试以下操作:
步骤 1:安装道具类型依赖项
npm/yarn install prop-types create-react-class
第 2 步:将以下内容添加到 node_modules/反应/索引.js
module.exports.PropTypes = require('prop-types');
let createClass;
Object.defineProperty(module.exports, 'createClass', {
get: function() {
if (!createClass) {
createClass = require('create-react-class').bind(module.exports);
}
return createClass;
}
});
参考: https://github.com/shoutem/ui/issues/328
通过导入PropTypes from 'prop-types'
而不是'react'
来解决它
import React, {Component } from "react";
import PropTypes from 'prop-types';