Skip to content

proptype validation too strict #332

Open
@mbohal

Description

@mbohal

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 #301 was merged.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions