UNPKG

@carbon/react

Version:

React components for the Carbon Design System

30 lines (26 loc) 813 B
/** * 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 { noopFn } from './noopFn.js'; /** * Logs a warning. * * The warning is only logged if the condition is not met and * `process.env.NODE_ENV !== 'production'` is truthy. * * @param condition - Condition to evaluate. * @param message - Warning message. * @throws Error if no `message` is provided. */ const warning = process.env.NODE_ENV !== 'production' ? (condition, message) => { if (typeof message === 'undefined') { throw new Error('`warning(condition, message)` requires a warning ' + 'format argument'); } if (!condition) { console.warn('Warning: ' + message); } } : noopFn; export { warning };