diff --git a/docs/developer-handbook.md b/docs/developer-handbook.md
index cc551126c390..3e3145102368 100644
--- a/docs/developer-handbook.md
+++ b/docs/developer-handbook.md
@@ -706,7 +706,7 @@ pattern that we tend to use:
```jsx
// SomeComponent.js
// React imports
-import warning from 'warning';
+import { warning } from '../../internal/warning';
let didWarnAboutDeprecation = false;
diff --git a/packages/components/src/components/modal/modal.js b/packages/components/src/components/modal/modal.js
index 3c3af913887f..dd1f530d2f00 100644
--- a/packages/components/src/components/modal/modal.js
+++ b/packages/components/src/components/modal/modal.js
@@ -4,6 +4,7 @@
* 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';
import settings from '../../globals/js/settings';
import mixin from '../../globals/js/misc/mixin';
diff --git a/packages/react/package.json b/packages/react/package.json
index b857c5e7693d..72563d445ec4 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -58,7 +58,6 @@
"lodash.throttle": "^4.1.1",
"react-is": "^16.8.6",
"use-resize-observer": "^6.0.0",
- "warning": "^3.0.0",
"window-or-global": "^1.0.1"
},
"devDependencies": {
diff --git a/packages/react/src/components/OverflowMenuItem/OverflowMenuItem.js b/packages/react/src/components/OverflowMenuItem/OverflowMenuItem.js
index 047e87e33468..164bea218032 100644
--- a/packages/react/src/components/OverflowMenuItem/OverflowMenuItem.js
+++ b/packages/react/src/components/OverflowMenuItem/OverflowMenuItem.js
@@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
+import { settings } from 'carbon-components';
+import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import classNames from 'classnames';
-import warning from 'warning';
-import { settings } from 'carbon-components';
import { match, keys } from '../../internal/keyboard';
+import { warning } from '../../internal/warning';
import deprecate from '../../prop-types/deprecate.js';
const { prefix } = settings;
diff --git a/packages/react/src/components/RadioButton/RadioButton.js b/packages/react/src/components/RadioButton/RadioButton.js
index 7a47add51a9c..1160947d2076 100644
--- a/packages/react/src/components/RadioButton/RadioButton.js
+++ b/packages/react/src/components/RadioButton/RadioButton.js
@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
+import { settings } from 'carbon-components';
+import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import classNames from 'classnames';
-import warning from 'warning';
-import { settings } from 'carbon-components';
+import { warning } from '../../internal/warning';
import uid from '../../tools/uniqueId';
const { prefix } = settings;
diff --git a/packages/react/src/components/RadioButtonGroup/RadioButtonGroup.js b/packages/react/src/components/RadioButtonGroup/RadioButtonGroup.js
index 0801bde14281..880f440b8214 100644
--- a/packages/react/src/components/RadioButtonGroup/RadioButtonGroup.js
+++ b/packages/react/src/components/RadioButtonGroup/RadioButtonGroup.js
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import RadioButton from '../RadioButton';
-import warning from 'warning';
+import { warning } from '../../internal/warning';
import { settings } from 'carbon-components';
const { prefix } = settings;
diff --git a/packages/react/src/components/SearchFilterButton/SearchFilterButton-test.js b/packages/react/src/components/SearchFilterButton/SearchFilterButton-test.js
index 3c56a411ff8a..cb4e381cd735 100644
--- a/packages/react/src/components/SearchFilterButton/SearchFilterButton-test.js
+++ b/packages/react/src/components/SearchFilterButton/SearchFilterButton-test.js
@@ -17,9 +17,7 @@ describe('[Deprecated] SearchFilterButton', () => {
let wrapper;
beforeEach(() => {
- jest.mock('warning', () => {
- return jest.fn();
- });
+ jest.mock('../../internal/warning');
SearchFilterButton = require('../SearchFilterButton').default;
wrapper = mount();
});
diff --git a/packages/react/src/components/SearchFilterButton/SearchFilterButton.js b/packages/react/src/components/SearchFilterButton/SearchFilterButton.js
index 294e21766188..d53892841584 100644
--- a/packages/react/src/components/SearchFilterButton/SearchFilterButton.js
+++ b/packages/react/src/components/SearchFilterButton/SearchFilterButton.js
@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
-import React from 'react';
-import PropTypes from 'prop-types';
-import warning from 'warning';
-import { settings } from 'carbon-components';
import { Filter16 } from '@carbon/icons-react';
+import { settings } from 'carbon-components';
+import PropTypes from 'prop-types';
+import React from 'react';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/components/SearchLayoutButton/SearchLayoutButton-test.js b/packages/react/src/components/SearchLayoutButton/SearchLayoutButton-test.js
index a48ed5a3491b..74cc4c34802a 100644
--- a/packages/react/src/components/SearchLayoutButton/SearchLayoutButton-test.js
+++ b/packages/react/src/components/SearchLayoutButton/SearchLayoutButton-test.js
@@ -17,9 +17,7 @@ describe('[Deprecated] SearchLayoutButton', () => {
let wrapper;
beforeEach(() => {
- jest.mock('warning', () => {
- return jest.fn();
- });
+ jest.mock('../../internal/warning');
SearchLayoutButton = require('../SearchLayoutButton').default;
wrapper = mount();
});
diff --git a/packages/react/src/components/SearchLayoutButton/SearchLayoutButton.js b/packages/react/src/components/SearchLayoutButton/SearchLayoutButton.js
index d24fec361fe8..fdf5286b1e8b 100644
--- a/packages/react/src/components/SearchLayoutButton/SearchLayoutButton.js
+++ b/packages/react/src/components/SearchLayoutButton/SearchLayoutButton.js
@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import warning from 'warning';
-import { settings } from 'carbon-components';
import { ListBulleted16, Grid16 } from '@carbon/icons-react';
+import { settings } from 'carbon-components';
+import PropTypes from 'prop-types';
+import React, { Component } from 'react';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/components/TileGroup/TileGroup.js b/packages/react/src/components/TileGroup/TileGroup.js
index 1c2034599252..907f85b07520 100644
--- a/packages/react/src/components/TileGroup/TileGroup.js
+++ b/packages/react/src/components/TileGroup/TileGroup.js
@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
+import { settings } from 'carbon-components';
import PropTypes from 'prop-types';
import React from 'react';
import RadioTile from '../RadioTile';
-import warning from 'warning';
-import { settings } from 'carbon-components';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/components/ToggleSmall/ToggleSmall-test.js b/packages/react/src/components/ToggleSmall/ToggleSmall-test.js
index db64de91893b..1acaab2c59b1 100644
--- a/packages/react/src/components/ToggleSmall/ToggleSmall-test.js
+++ b/packages/react/src/components/ToggleSmall/ToggleSmall-test.js
@@ -16,9 +16,7 @@ describe('ToggleSmall', () => {
let ToggleSmall;
beforeEach(() => {
- jest.mock('warning', () => {
- return jest.fn();
- });
+ jest.mock('../../internal/warning');
ToggleSmall = require('../ToggleSmall').default;
});
diff --git a/packages/react/src/components/ToggleSmall/ToggleSmall.js b/packages/react/src/components/ToggleSmall/ToggleSmall.js
index 2aa82fdbaabb..8e4f3f1ba758 100644
--- a/packages/react/src/components/ToggleSmall/ToggleSmall.js
+++ b/packages/react/src/components/ToggleSmall/ToggleSmall.js
@@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
+import { settings } from 'carbon-components';
+import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import classNames from 'classnames';
-import { settings } from 'carbon-components';
import { keys, match } from '../../internal/keyboard';
-import warning from 'warning';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/components/Toolbar/Toolbar-test.js b/packages/react/src/components/Toolbar/Toolbar-test.js
index e95af1ff9e22..28eaefc5d5a9 100644
--- a/packages/react/src/components/Toolbar/Toolbar-test.js
+++ b/packages/react/src/components/Toolbar/Toolbar-test.js
@@ -22,9 +22,7 @@ describe('[Deprecated] Toolbar', () => {
beforeEach(() => {
// Toolbar is deprecated
- jest.mock('warning', () => {
- return jest.fn();
- });
+ jest.mock('../../internal/warning');
Toolbar = require('../Toolbar').default;
ToolbarItem = require('../Toolbar').ToolbarItem;
diff --git a/packages/react/src/components/Toolbar/Toolbar.js b/packages/react/src/components/Toolbar/Toolbar.js
index ad8e59aaaa3a..76e1f9b3712c 100644
--- a/packages/react/src/components/Toolbar/Toolbar.js
+++ b/packages/react/src/components/Toolbar/Toolbar.js
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
import ToolbarSearch from '../ToolbarSearch';
import classNames from 'classnames';
import { settings } from 'carbon-components';
-import warning from 'warning';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/components/ToolbarSearch/ToolbarSearch.js b/packages/react/src/components/ToolbarSearch/ToolbarSearch.js
index 4a71d5701b74..dd31bd489550 100644
--- a/packages/react/src/components/ToolbarSearch/ToolbarSearch.js
+++ b/packages/react/src/components/ToolbarSearch/ToolbarSearch.js
@@ -11,7 +11,7 @@ import classNames from 'classnames';
import { Search16 } from '@carbon/icons-react';
import { settings } from 'carbon-components';
import ClickListener from '../../internal/ClickListener';
-import warning from 'warning';
+import { warning } from '../../internal/warning';
const { prefix } = settings;
diff --git a/packages/react/src/internal/FloatingMenu.js b/packages/react/src/internal/FloatingMenu.js
index 2c2cfa436b36..950b9d732129 100644
--- a/packages/react/src/internal/FloatingMenu.js
+++ b/packages/react/src/internal/FloatingMenu.js
@@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
-import warning from 'warning';
import PropTypes from 'prop-types';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -13,6 +12,7 @@ import window from 'window-or-global';
import { settings } from 'carbon-components';
import OptimizedResize from './OptimizedResize';
import { selectorFocusable, selectorTabbable } from './keyboard/navigation';
+import { warning } from './warning';
import wrapFocus from './wrapFocus';
const { prefix } = settings;
diff --git a/packages/react/src/internal/__mocks__/warning.js b/packages/react/src/internal/__mocks__/warning.js
new file mode 100644
index 000000000000..76577529e782
--- /dev/null
+++ b/packages/react/src/internal/__mocks__/warning.js
@@ -0,0 +1,10 @@
+/**
+ * Copyright IBM Corp. 2016, 2018
+ *
+ * This source code is licensed under the Apache-2.0 license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+module.exports = {
+ warning: jest.fn(),
+};
diff --git a/packages/react/src/internal/useControllableState.js b/packages/react/src/internal/useControllableState.js
index 68517e38c6f8..5c0f10dc7745 100644
--- a/packages/react/src/internal/useControllableState.js
+++ b/packages/react/src/internal/useControllableState.js
@@ -6,7 +6,7 @@
*/
import { useEffect, useRef, useState } from 'react';
-import { warn } from './warn';
+import { warning } from './warning';
export function useControllableState(
controlledState,
@@ -47,7 +47,7 @@ export function useControllableState(
// Uncontrolled -> Controlled
// If the component prop is uncontrolled, the prop value should be undefined
if (controlled.current === false && controlledState !== undefined) {
- warn(
+ warning(
false,
'A component is changing an uncontrolled component to be controlled. ' +
'This is likely caused by the value changing to a defined value ' +
@@ -60,7 +60,7 @@ export function useControllableState(
// Controlled -> Uncontrolled
// If the component prop is controlled, the prop value should be defined
if (controlled.current === true && controlledState === undefined) {
- warn(
+ warning(
false,
'A component is changing a controlled component to be uncontrolled. ' +
'This is likely caused by the value changing to an undefined value ' +
diff --git a/packages/react/src/internal/warn.js b/packages/react/src/internal/warn.js
deleted file mode 100644
index 3993b18cf0ae..000000000000
--- a/packages/react/src/internal/warn.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright IBM Corp. 2016, 2018
- *
- * This source code is licensed under the Apache-2.0 license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-const emptyFunction = function () {};
-
-const warn = __DEV__
- ? function warn(condition, format, ...args) {
- if (format === undefined) {
- throw new Error(
- '`warn(condition, format, ...args)` requires a warning ' +
- 'message argument'
- );
- }
-
- if (!condition) {
- let index = 0;
- const message = format.replace(/%s/g, () => {
- return args[index++];
- });
-
- console.warn('Warning: ' + message);
- }
- }
- : emptyFunction;
-
-export { warn };
diff --git a/packages/react/src/prop-types/__tests__/deprecate-test.js b/packages/react/src/prop-types/__tests__/deprecate-test.js
index 26d9c3d5e3fc..5089289e89f2 100644
--- a/packages/react/src/prop-types/__tests__/deprecate-test.js
+++ b/packages/react/src/prop-types/__tests__/deprecate-test.js
@@ -13,8 +13,8 @@ describe('deprecate', () => {
beforeEach(() => {
jest.resetModules();
- jest.mock('warning');
- warning = require('warning');
+ jest.mock('../../internal/warning');
+ warning = require('../../internal/warning').warning;
deprecate = require('../deprecate').default;
mockPropType = jest.fn();
mockArgs = [{ propName: true }, 'propName', 'ComponentName'];
diff --git a/packages/react/src/prop-types/deprecate.js b/packages/react/src/prop-types/deprecate.js
index 7ac4374d7493..3de11f849ebb 100644
--- a/packages/react/src/prop-types/deprecate.js
+++ b/packages/react/src/prop-types/deprecate.js
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-import warning from 'warning';
+import { warning } from '../internal/warning';
const didWarnAboutDeprecation = {};
diff --git a/yarn.lock b/yarn.lock
index 95ed59bceb47..0b9392c716e0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9259,7 +9259,6 @@ __metadata:
string-replace-loader: ^2.1.0
terser-webpack-plugin: ^2.3.2
use-resize-observer: ^6.0.0
- warning: ^3.0.0
webpack: ^4.41.5
whatwg-fetch: ^2.0.3
window-or-global: ^1.0.1