您的位置:首页 > 移动开发 > Objective-C

React Native Undefined is not an object(evaluating ‘_react2.PropTypes.func’)

2018-01-08 15:09 2296 查看
我原来的写法

import React,
{ Component, PropTypes } from
'react';

export default class CommonTitle
extends Component {
    render() {
        return (
          …
        )
    }

 }

CommonTitle.propTypes = {
    onTitleClick: PropTypes.func.isRequired
}
PropTypes 放在了react 中引入,但是还是出错
Undefined is not an object(evaluating ‘_react2.PropTypes.func’)

正确写法:

import React,
{ Component } from 'react';
import PropTypes from
'prop-types';
把PropTypes 从prop-types 中引入
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐