Consider having a key and value map object like below:
export const PlaceholderVisibility = {
Always: undefined,
Never: null,
OnFocus: true,
OnBlur: false
}
How would you use PropTypes
to only allow values specified in the existing object?
Here is what I tried:
import PropTypes from 'prop-types';
export const myTypes = {
// ...
visibility: PropTypes.oneOf(PlaceholderVisibility)
}
But I am currently using PropTypes.bool
as that seems to work for this situation, but still, that would not work when for example one of the values was of type string.