Tekkaman

导航

 

Typechecking With PropTypes

1、props类型检查

  React has some built-in typechecking abilities. To run typechecking on the props for a component, you can assign the special propTypesproperty:

  

2、child个数设置

  With React.PropTypes.element you can specify that only a single child can be passed to a component as children.

  

3、Default Prop Values

  

参考:https://facebook.github.io/react/docs/typechecking-with-proptypes.html

posted on 2017-03-23 19:33  Tekkaman  阅读(226)  评论(0编辑  收藏  举报