fix for TableBody
This commit is contained in:
parent
062b0f5b99
commit
ec1e1933e8
@ -11,9 +11,11 @@ const TableBody = ({ children, className, style }) => {
|
|||||||
)}
|
)}
|
||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
{React.Children.map(children, child =>
|
{React.isValidElement(children)
|
||||||
React.cloneElement(child, { isTableHead: false })
|
? React.cloneElement(children, {
|
||||||
)}
|
isTableHead: false,
|
||||||
|
})
|
||||||
|
: children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -24,7 +26,26 @@ TableBody.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TableBody.propTypes = {
|
TableBody.propTypes = {
|
||||||
children: PropTypes.node.isRequired,
|
children: function(props, propName, componentName) {
|
||||||
|
const elements = React.Children.toArray(props.children);
|
||||||
|
const isString = elements.some(child => typeof child === 'string');
|
||||||
|
|
||||||
|
if (isString) {
|
||||||
|
return new Error(
|
||||||
|
`Failed prop type: Invalid prop ${propName} supplied to ${componentName}, expected a valid element instead of a string.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isInvalidElement = elements.some(
|
||||||
|
child => !React.isValidElement(child)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInvalidElement) {
|
||||||
|
return new Error(
|
||||||
|
`Failed prop type: Invalid prop ${propName} supplied to ${componentName}, expected a valid node element.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user