0
当你创建一个组件A其中包含一个组件B通过添加一些逻辑?你是否应该提醒所需propTypes B in A?包装组件是否应提醒包装组件的propType?
例如之实践:
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}
/>
);
}
爷那是什么我也这样想在这种情况下HorizontalGauge propTypes应该像 'propTypes:{... GenericHorizontalGauge.propTypes,showPercentage:PropTypes.bool}' – Nicolas