React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)
How React PropTypes allow different types for one prop?
mid LevelCode ExampleFormsPerformance
You can use the oneOfType() method of PropTypes.
For example, the height property can be defined with either string or number type as below:
javascript
Component.propTypes = {
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};