Since oneOf
only accepts array, I decided to define a checker function and written the following code, however, it does not work.
const mapping = {
foo: ["aaa", "bbb"],
bar: ["ccc", "ddd"]
}
MyComponent.propTypes = {
variant: (props, propName, componentName) => {
if(props[propName]) PropTypes.oneOf(mapping[props.type])
},
tag: PropTypes.string
};
What is the right way to use another built-in checker function in a custom checker function? Is it possible?