UNPKG

1.02 kBJavaScriptView Raw
1import { warn } from './warn';
2/**
3 * Warns when two props which are mutually exclusive are both being used.
4 *
5 * @public
6 * @param componentName - The name of the component being used.
7 * @param props - The props passed into the component.
8 * @param exclusiveMap - A map where the key is a parameter, and the value is the other parameter.
9 */
10export function warnMutuallyExclusive(componentName, props, exclusiveMap) {
11 if (process.env.NODE_ENV !== 'production') {
12 for (var propName in exclusiveMap) {
13 if (props && props[propName] !== undefined) {
14 var propInExclusiveMapValue = exclusiveMap[propName];
15 if (propInExclusiveMapValue && props[propInExclusiveMapValue] !== undefined) {
16 warn(componentName + " property '" + propName + "' is mutually exclusive with '" + exclusiveMap[propName] + "'. " +
17 "Use one or the other.");
18 }
19 }
20 }
21 }
22}
23//# sourceMappingURL=warnMutuallyExclusive.js.map
\No newline at end of file