Here is pro example of using multi proptypes and single proptype.
import React, { Component } from 'react';
import { string, shape, array, oneOfType } from 'prop-types';
class MyComponent extends Component {
/**
* Render
*/
render() {
const { title, data } = this.props;
return (
<>
{title}
<br />
{data}
</>
);
}
}
/**
* Define component props
*/
MyComponent.propTypes = {
data: oneOfType([array, string, shape({})]),
title: string,
};
export default MyComponent;