mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
* Rename lowPriorityWarning to lowPriorityWarningWithoutStack This maintains parity with the other warning-like functions. * Duplicate the toWarnDev tests to test toLowPriorityWarnDev * Make a lowPriorityWarning version of warning.js * Extract both variants in print-warning Avoids parsing lowPriorityWarning.js itself as the way it forwards the call to lowPriorityWarningWithoutStack is not analyzable.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
|
|
import ReactSharedInternals from 'shared/ReactSharedInternals';
|
|
|
|
/**
|
|
* Similar to invariant but only logs a warning if the condition is not met.
|
|
* This can be used to log issues in development environments in critical
|
|
* paths. Removing the logging code for production environments will keep the
|
|
* same logic and follow the same code paths.
|
|
*/
|
|
|
|
let lowPriorityWarning = lowPriorityWarningWithoutStack;
|
|
|
|
if (__DEV__) {
|
|
lowPriorityWarning = function(condition, format, ...args) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
const stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
lowPriorityWarningWithoutStack(false, format + '%s', ...args, stack);
|
|
};
|
|
}
|
|
|
|
export default lowPriorityWarning;
|