码迷,mamicode.com
首页 > 其他好文 > 详细

React 使用 PropTypes 进行类型检查

时间:2018-04-16 16:22:18      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:boot   .com   react   html   组件   tps   https   default   检查   

  • 注意: React.PropTypes 自 React v15.5 起已弃用。请使用 prop-types 库代替。

  • defaultProps 用来确保 this.props.name 在父组件没有特别指定的情况下,有一个初始值。类型检查发生在 defaultProps 赋值之后,所以类型检查也会应用在 defaultProps 上面。

  • 出处:https://react.bootcss.com/react/docs/typechecking-with-proptypes.html

React 使用 PropTypes 进行类型检查

标签:boot   .com   react   html   组件   tps   https   default   检查   

原文地址:https://www.cnblogs.com/cag2050/p/8855951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!