mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
415ee0e6ea
This backports a deprecation warning for legacy context, even when Strict Mode is not enabled. I didn't bother to update all the tests because the tests are in such a different state than what's on `main`, and on `main` we already updated the tests accordingly. So instead I silenced the warnings in our test config, like we've done for other warnings in the past.
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = function shouldIgnoreConsoleError(format, args) {
|
|
if (__DEV__) {
|
|
if (typeof format === 'string') {
|
|
if (format.indexOf('Error: Uncaught [') === 0) {
|
|
// This looks like an uncaught error from invokeGuardedCallback() wrapper
|
|
// in development that is reported by jsdom. Ignore because it's noisy.
|
|
return true;
|
|
}
|
|
if (format.indexOf('The above error occurred') === 0) {
|
|
// This looks like an error addendum from ReactFiberErrorLogger.
|
|
// Ignore it too.
|
|
return true;
|
|
}
|
|
if (
|
|
format.indexOf('ReactDOM.render is no longer supported in React 18') !==
|
|
-1 ||
|
|
format.indexOf(
|
|
'ReactDOM.hydrate is no longer supported in React 18'
|
|
) !== -1
|
|
) {
|
|
// We haven't finished migrating our tests to use createRoot.
|
|
return true;
|
|
}
|
|
if (
|
|
format.indexOf(
|
|
'uses the legacy contextTypes API which is no longer supported and will be removed'
|
|
) !== -1 ||
|
|
format.indexOf(
|
|
'uses the legacy childContextTypes API which is no longer supported and will be removed'
|
|
) !== -1
|
|
) {
|
|
// This is a backported warning. In `main`, there's a different warning
|
|
// (and it's fully tested). Not going to bother upgrading all the tests
|
|
// on this old release branch, so let's just silence it instead.
|
|
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;
|
|
};
|