@carbon/react
Version:
React components for the Carbon Design System
25 lines (21 loc) • 832 B
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 './warning.js';
const deprecateFieldOnObject = (object, field, Component, message) => {
const didWarnAboutDeprecation = {};
Object.defineProperty(object, field, {
enumerable: true,
get: () => {
if (!didWarnAboutDeprecation[field]) {
process.env.NODE_ENV !== "production" ? warning(false, `The ${field} field has been deprecated on the ${object.displayName} object. ` + `Please import and use ${Component.displayName || Component.name || 'the field'} directly.`) : void 0;
didWarnAboutDeprecation[field] = true;
}
return Component;
}
});
};
export { deprecateFieldOnObject };