首页 > 代码库 > Typechecking With PropTypes

Typechecking With PropTypes

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

Typechecking With PropTypes