const warningWWW = require('warning');
let suppressWarning = false;
export function setSuppressWarning(newSuppressWarning) {
if (__DEV__) {
suppressWarning = newSuppressWarning;
}
}
export function warn(format, ...args) {
if (__DEV__) {
if (!suppressWarning) {
printWarning('warn', format, args);
}
}
}
export function error(format, ...args) {
if (__DEV__) {
if (!suppressWarning) {
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
if (__DEV__) {
const React = require('react');
const ReactSharedInternals =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (ReactSharedInternals != null) {
const ReactDebugCurrentFrame =
ReactSharedInternals.ReactDebugCurrentFrame;
const stack = ReactDebugCurrentFrame.getStackAddendum();
if (stack !== '') {
format += '%s';
args.push(stack);
}
}
args.unshift(format);
args.unshift(false);
warningWWW.apply(null, args);
}
}