I want to share my solution for using conditional propTypes on a single prop value. Which is the case for showDropdown
which and receive either bool || string
.
const isBoolean = (val) => typeof val === 'boolean';
const isSring = (val) => typeof val === 'string' || val instanceof String;
Dropdown.propTypes = {
data: PropTypes.array.isRequired,
showDropdown: isRequiredIf(PropTypes.bool, props => (isBoolean(props.showDropdown) || isSring(props.showDropdown))),
id: PropTypes.string.isRequired,
classname: PropTypes.string,
}
NumaX hope this will help some fellow dev with the same doubt!!!