本文介绍了PropTypes React Native不是对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在响应本机代码时遇到PropTypes问题:
I have a problem with PropTypes in react native my code :
import React, { Component, PropTypes } from 'react';
import { Text } from 'react-native';
export default class Star extends Component {
render() {
return ( <Text> Hello </Text> );
}
}
Star.propTypes = {
fullStar: PropTypes.string.isRequired,
halfStar: PropTypes.string.isRequired,
emptyStar: PropTypes.string.isRequired,
half: PropTypes.bool,
count: PropTypes.number,
size: PropTypes.number,
}
Star.defaultProps = {
fullStar: "",
halfStar: "",
emtyStar: "",
half: 'true',
count: 5,
size: 30,
}
我的错误未定义不是对象(正在评估'_react2.PropTypes.string')
My error is undefined is not an object (evaluating '_react2.PropTypes.string')
感谢阅读;)
推荐答案
PropTypes
移到了单独的程序包中.使用prop-types
程序包.
PropTypes
moved into separate package. Use prop-types
package.
更多信息此处.
React.PropTypes
已经移到了另一个包中 v15.5.请改用 prop-types库.我们提供 codemod脚本来自动执行转换.
React.PropTypes
has moved into a different package since React v15.5. Please use the prop-types library instead. We provide a codemod script to automate the conversion.
这篇关于PropTypes React Native不是对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!