道具验证中缺少功能部件eslint'日期'

时间:2018-08-21 09:58:16

标签: javascript reactjs eslint

我使用了protoTypes,但是却抛出'date' is missing in props validation

function SpreadTitle(props) {
  return (
    <div >
      <div>{props.date}</div>
      <div>latestUpdateTime: {props.latestUpdateTime}</div>
    </div>
  )
}

SpreadTitle.protoTypes = {
  date: React.PropTypes.string,
  latestUpdateTime: React.PropTypes.string,
}
SpreadTitle.defaultProps = {
  date: '',
  latestUpdateTime: ''
}

我仅在功能组件中遇到此错误,它可以工作,但会发出警告
花了2个小时尝试解决此问题,我们将不胜感激

1 个答案:

答案 0 :(得分:0)

将“ protoTypes”更改为“ propTypes”

SpreadTitle.propTypes = {
  date: React.PropTypes.string,
  latestUpdateTime: React.PropTypes.string,
}