Files
med-notes/.pnpm-store/v10/files/ed/21652af73f5afde615ac5574efc133a784c54175e097500b36ca4f2d36338bd0f40d8668930f9ff4e69183f1ca810b2506193523eb096dec8b5266175a9446
2025-05-09 05:30:08 +02:00

31 lines
851 B
Plaintext

// @flow
const isProduction: boolean = process.env.NODE_ENV === 'production';
export default function warning(condition: mixed, message: string): void {
// don't do anything in production
// wrapping in production check for better dead code elimination
if (!isProduction) {
// condition passed: do not log
if (condition) {
return;
}
// Condition not passed
const text: string = `Warning: ${message}`;
// check console for IE9 support which provides console
// only with open devtools
if (typeof console !== 'undefined') {
console.warn(text);
}
// Throwing an error and catching it immediately
// to improve debugging
// A consumer can use 'pause on caught exceptions'
// https://github.com/facebook/react/issues/4216
try {
throw Error(text);
} catch (x) {}
}
}