I have a React component which I would like to enforce one of two props to be provided - if neither is provided I'd like to be able to trigger a PropType warning:
MyComponent.propTypes = {
firstProp: PropTypes.string.isRequired, // required only if `otherProp` not provided
otherProp: PropTypes.string.isRequired, // required only if `firstProp` not provided
}
I believe this is possible with AirBnB's prop-types but I'm wondering if this can be done with only React PropTypes.