【发布时间】:2015-04-28 12:19:36
【问题描述】:
当您创建一个组件 A 通过添加一些逻辑来包装组件 B 时?您是否应该在 A 中提醒 B 所需的 propTypes ?
实际例子:
const HorizontalGauge = React.createClass({
propTypes: {
//Should I remind required propTypes of GenericHorizontalGauge ?
showPercentage: PropTypes.bool,
},
_formatStackValuePercentage() {
...
}
render() {
let { showPercentage, ...otherProps } = this.props;
return (
<GenericHorizontalGauge
formatValue={showPercentage && this._formatValuePercentage}
{...otherProps}
/>
);
}
【问题讨论】:
标签: reactjs