1 | export default function requirePropFactory(componentNameInError) {
|
2 | if (process.env.NODE_ENV === 'production') {
|
3 | return () => null;
|
4 | }
|
5 |
|
6 | const requireProp = requiredProp => (props, propName, componentName, location, propFullName) => {
|
7 | const propFullNameSafe = propFullName || propName;
|
8 |
|
9 | if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
|
10 | return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` must be used on \`${requiredProp}\`.`);
|
11 | }
|
12 |
|
13 | return null;
|
14 | };
|
15 |
|
16 | return requireProp;
|
17 | } |
\ | No newline at end of file |