facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

`childrenOfType`? #209

Closed ryan-sandy closed 5 years ago

ryan-sandy commented 6 years ago

How would people feel about a children shorthand?

const children = PropTypes.oneOfType([
  PropTypes.arrayOf(PropTypes.node),
  PropTypes.node
])
ljharb commented 6 years ago

airbnb-prop-types has childrenOf, which is a bit more useful than just “node” imo.

ryan-sandy commented 6 years ago

@ljharb That's a nifty package. I didn't know it existed. Thanks for the tip. I think this will solve my problems.

oleblaesing commented 6 years ago

Is something like childrenOfType also planned for prop-types? It's quite useful, to guarantee the correct use of compound components. 😄

ljharb commented 5 years ago

Closing as a duplicate of #61.