I want to allow a component to having one of two possible proptypes (string or undefined). I am using PropTypes.oneOfType to do this.
import React from 'react';
import PropTypes from 'prop-types';
Product.propTypes = {
productTag: PropTypes.oneOfType([
PropTypes.string, undefined
]),
};
Product.defaultProps = {
productTag: undefined
};
Is that the correct way?