FrontendDeveloper.in

React question detail

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]),
};
Back to all React questions
Get LinkedIn Premium at Rs 399