如何验证应该接受组件的反应道具

How to validate react prop that should accept Component

假设我希望我的组件接受类型为 React.Component

的 属性
const MyComponent = ({ child: Child }) => 
  <div>
    <Child {...childProps} />
  </div>

MyComponent.propTypes = {
  child: PropTypes.[???].isRequired
}

prop-types 中是否有我可以使用的 React.Component 验证器?

edit: I've tried with PropTypes.element, but I get an error Failed prop type: Invalid prop 'el' of type 'function' supplied to 'Test', expected a single ReactElement.

https://codesandbox.io/s/qk0jyq13yj

edit2: I've just found in material-ui they have custom validation

使用 element 属性

MyComponent.propTypes = {
  child: PropTypes.element.isRequired
}

instanceOf

MyComponent.propTypes = {
  child: PropTypes.instanceOf(ReactComponentName).isRequired
}