加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – PropTypes React Native不是对象

发布时间:2020-12-15 20:17:57 所属栏目:百科 来源:网络整理
导读:我的反应原生代码我的PropTypes有问题: 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有问题:

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,}

我的错误是undefined不是一个对象(评估’_react2.PropTypes.string’)

谢谢你的阅读;)

解决方法

PropTypes移动到单独的包中.使用prop-types包.

更多信息here.

Note:

React.PropTypes has moved into a different package since React v15.5. Please use the 07001 instead. We provide a codemod script to automate the conversion.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读