@@ -35,7 +35,10 @@ import {
3535import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber' ;
3636import invariant from 'shared/invariant' ;
3737import isArray from 'shared/isArray' ;
38- import { enableSchedulingProfiler } from 'shared/ReactFeatureFlags' ;
38+ import {
39+ enableSchedulingProfiler ,
40+ consoleManagedByDevToolsDuringStrictMode ,
41+ } from 'shared/ReactFeatureFlags' ;
3942import ReactSharedInternals from 'shared/ReactSharedInternals' ;
4043import { getPublicInstance } from './ReactFiberHostConfig' ;
4144import {
@@ -107,6 +110,7 @@ export {
107110
108111import * as Scheduler from './Scheduler' ;
109112import { setSuppressWarning } from 'shared/consoleWithStackDev' ;
113+ import { disableLogs , reenableLogs } from 'shared/ConsolePatchingDev' ;
110114
111115type OpaqueRoot = FiberRoot ;
112116
@@ -717,14 +721,23 @@ export function getIsStrictModeForDevtools() {
717721}
718722
719723export function setIsStrictModeForDevtools ( newIsStrictMode : boolean ) {
720- // We're in a test because Scheduler.unstable_yieldValue only exists
721- // in SchedulerMock. To reduce the noise in strict mode tests,
722- // suppress warnings and disable scheduler yielding during the double render
723- if ( typeof Scheduler . unstable_yieldValue === 'function' ) {
724- Scheduler . unstable_setDisableYieldValue ( newIsStrictMode ) ;
725- setSuppressWarning ( newIsStrictMode ) ;
726- }
727724 isStrictMode = newIsStrictMode ;
725+
726+ if ( consoleManagedByDevToolsDuringStrictMode ) {
727+ // We're in a test because Scheduler.unstable_yieldValue only exists
728+ // in SchedulerMock. To reduce the noise in strict mode tests,
729+ // suppress warnings and disable scheduler yielding during the double render
730+ if ( typeof Scheduler . unstable_yieldValue === 'function' ) {
731+ Scheduler . unstable_setDisableYieldValue ( newIsStrictMode ) ;
732+ setSuppressWarning ( newIsStrictMode ) ;
733+ }
734+ } else {
735+ if ( newIsStrictMode ) {
736+ disableLogs ( ) ;
737+ } else {
738+ reenableLogs ( ) ;
739+ }
740+ }
728741}
729742
730743export function injectIntoDevTools ( devToolsConfig : DevToolsConfig ) : boolean {
0 commit comments