How React PropTypes allow different types for one prop?

You can use oneOfType() method of PropTypes.

For example, the height property can be defined with either string or number type as below:

Component.PropTypes = {
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};

Author of content
Edit this page

Made by Michael Sakhniuk

Twitter