mirror of
https://github.com/facebook/react.git
synced 2026-02-24 04:33:04 +00:00
I originally added this in #21021 but I didn't mention why and I don't quite remember why. Maybe because there were no other message? However at the time the recoverable errors mechanism didn't exist. Today I believe all cases where this happens will trigger another recoverable error. Namely these two:9f33f699e4/packages/react-reconciler/src/ReactFiberBeginWork.js (L1442-L1446)9f33f699e4/packages/react-reconciler/src/ReactFiberBeginWork.js (L2962-L2965)Therefore this is just an extra unnecessary log.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = function shouldIgnoreConsoleError(format, args) {
|
|
if (__DEV__) {
|
|
if (typeof format === 'string') {
|
|
if (
|
|
args[0] != null &&
|
|
((typeof args[0] === 'object' &&
|
|
typeof args[0].message === 'string' &&
|
|
typeof args[0].stack === 'string') ||
|
|
(typeof args[0] === 'string' &&
|
|
args[0].indexOf('An error occurred in ') === 0))
|
|
) {
|
|
// This looks like an error with addendum from ReactFiberErrorLogger.
|
|
// They are noisy too so we'll try to ignore them.
|
|
return true;
|
|
}
|
|
if (
|
|
format.indexOf('ReactDOM.render was removed in React 19') !== -1 ||
|
|
format.indexOf('ReactDOM.hydrate was removed in React 19') !== -1 ||
|
|
format.indexOf(
|
|
'ReactDOM.render has not been supported since React 18'
|
|
) !== -1 ||
|
|
format.indexOf(
|
|
'ReactDOM.hydrate has not been supported since React 18'
|
|
) !== -1
|
|
) {
|
|
// We haven't finished migrating our tests to use createRoot.
|
|
return true;
|
|
}
|
|
}
|
|
} 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;
|
|
};
|