ReactJS “TypeError: Cannot read property 'array' of undefined”

前端 未结 4 697
感情败类
感情败类 2021-01-04 05:31

While running this code I got error on the first line on App.propTypes

TypeError: Cannot read property \'array\' of undefined

4条回答
  •  伪装坚强ぢ
    2021-01-04 06:21

    Change this:

    App.propTypes = {
       propArray: React.PropTypes.array.isRequired, //I got error over here
       propBool: React.PropTypes.bool.isRequired,
       propFunc: React.PropTypes.func,
       propNumber: React.PropTypes.number,
       propString: React.PropTypes.string,
       propObject: React.PropTypes.object
    }
    

    to:

    App.propTypes = {
      propArray: PropTypes.array.isRequired,
      propBool: PropTypes.bool.isRequired,
      propFunc: PropTypes.func,
      propNumber: PropTypes.number,
      propString: PropTypes.string,
      propObject: PropTypes.object
    }`
    

提交回复
热议问题