당신은 소품 이름
// Generate a custom React validation function
function eitherProp(prop1, prop2) {
return (props, propName, componentName) => {
const hasProp1 = typeof props[ prop1 ] === 'object';
const hasProp2 = typeof props[ prop2 ] === 'object';
// If both are provided, or neither, error
if((hasProp1 && hasProp2) || !(hasProp1 || hasProp2)) {
return new Error(`Please provide either ${prop1} or ${prop2} of type object, not both`);
}
};
}
// Generate a reusable function for both props
const propsOneOrTwo = eitherProp('propsOne', 'propsTwo');
static propTypes = {
propsOne: propsOneOrTwo,
propsTwo: propsOneOrTwo
};
[이 답변] (http://stackoverflow.com/a/33982256/1301872) 도움이 될 것 같아요. –