react-ui icon indicating copy to clipboard operation
react-ui copied to clipboard

proptype validation too strict

Open mbohal opened this issue 4 years ago • 0 comments

In the following components:

  • CTA
  • Card
  • FormLayout
  • Media
  • Tabs

we validate the children prop with:

  children: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.arrayOf(PropTypes.element),
  ]).isRequired,

This is too strict, because it fails when false is passed in. This is common with idomatic code such as:

<CTA>
  {condition && <CTAStart />}
</CTA>

We should probably use children: PropTypes.node.isRequired to revert it to the state before https://github.com/react-ui-org/react-ui/pull/301 was merged.

Since propType validation is off in production builds, this has no effect on production code.

mbohal avatar Nov 05 '21 12:11 mbohal