@carbon/react
Version:
React components for the Carbon Design System
29 lines (25 loc) • 1.01 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { warning } from '../internal/warning.js';
const didWarnAboutDeprecation = {};
function deprecate(propType, message) {
function checker(props, propName, componentName, ...rest) {
if (props[propName] === undefined) {
return;
}
if (!didWarnAboutDeprecation[componentName] || !didWarnAboutDeprecation[componentName][propName]) {
didWarnAboutDeprecation[componentName] = {
...didWarnAboutDeprecation[componentName],
[propName]: true
};
process.env.NODE_ENV !== "production" ? warning(false, message || `The prop \`${propName}\` has been deprecated for the ` + `${componentName} component. It will be removed in the next major ` + `release`) : void 0;
}
return propType(props, propName, componentName, ...rest);
}
return checker;
}
export { deprecate as default };