将子项描述为instanceOf或具有prop-types的instanceOf的数组

时间:2018-05-03 16:36:15

标签: reactjs react-proptypes

我试图在我的组件中强制执行特定类型的孩子。

children: PropTypes.oneOfType([
  PropTypes.instanceOf(Column),
  PropTypes.arrayOf(PropTypes.instanceOf(Column))
])

用法

<Table data={data}>
  <Column field='foo' />
  <Column field='bar' />
</Table>

<Table data={data}>
  <Column field='baz' />
</Table>

我仍然会收到上述两个警告。

  

警告:道具类型失败:提供给的道具children无效   Table

实现这一目标的正确方法是什么?

0 个答案:

没有答案