2018-08-15 17:44:46 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
2024-02-01 18:26:33 -05:00
|
|
|
module.exports = function shouldIgnoreConsoleError(
|
|
|
|
|
format,
|
|
|
|
|
args,
|
|
|
|
|
{TODO_ignoreHydrationErrors} = {TODO_ignoreHydrationErrors: false}
|
|
|
|
|
) {
|
2018-08-15 17:44:46 +01:00
|
|
|
if (__DEV__) {
|
|
|
|
|
if (typeof format === 'string') {
|
2024-03-11 17:17:07 -07:00
|
|
|
if (
|
|
|
|
|
args[0] != null &&
|
|
|
|
|
typeof args[0].message === 'string' &&
|
|
|
|
|
typeof args[0].stack === 'string'
|
|
|
|
|
) {
|
|
|
|
|
// This looks like an error with addendum from ReactFiberErrorLogger.
|
|
|
|
|
// They are noisy too so we'll try to ignore them.
|
2018-08-15 17:44:46 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2021-06-09 16:46:55 -04:00
|
|
|
if (
|
2024-03-26 17:25:53 -04:00
|
|
|
format.indexOf('ReactDOM.render was removed in React 19') !== -1 ||
|
|
|
|
|
format.indexOf('ReactDOM.hydrate was removed in React 19') !== -1 ||
|
2021-06-09 16:46:55 -04:00
|
|
|
format.indexOf(
|
2024-03-26 17:25:53 -04:00
|
|
|
'ReactDOM.render has not been supported since React 18'
|
|
|
|
|
) !== -1 ||
|
|
|
|
|
format.indexOf(
|
|
|
|
|
'ReactDOM.hydrate has not been supported since React 18'
|
2021-06-09 16:46:55 -04:00
|
|
|
) !== -1
|
|
|
|
|
) {
|
|
|
|
|
// We haven't finished migrating our tests to use createRoot.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-02-01 18:26:33 -05:00
|
|
|
if (
|
|
|
|
|
TODO_ignoreHydrationErrors &&
|
|
|
|
|
format.indexOf(
|
|
|
|
|
'An error occurred during hydration. The server HTML was replaced with client content in'
|
|
|
|
|
) !== -1
|
|
|
|
|
) {
|
|
|
|
|
// This also gets logged by onRecoverableError, so we can ignore it.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-08-15 17:44:46 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
format != null &&
|
|
|
|
|
typeof format.message === 'string' &&
|
|
|
|
|
typeof format.stack === 'string' &&
|
|
|
|
|
args.length === 0
|
|
|
|
|
) {
|
|
|
|
|
// In production, ReactFiberErrorLogger logs error objects directly.
|
|
|
|
|
// They are noisy too so we'll try to ignore them.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Looks legit
|
|
|
|
|
return false;
|
|
|
|
|
};
|