@@ -35,7 +35,10 @@ import {
35
35
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber' ;
36
36
import invariant from 'shared/invariant' ;
37
37
import isArray from 'shared/isArray' ;
38
- import { enableSchedulingProfiler } from 'shared/ReactFeatureFlags' ;
38
+ import {
39
+ enableSchedulingProfiler ,
40
+ consoleManagedByDevToolsDuringStrictMode ,
41
+ } from 'shared/ReactFeatureFlags' ;
39
42
import ReactSharedInternals from 'shared/ReactSharedInternals' ;
40
43
import { getPublicInstance } from './ReactFiberHostConfig' ;
41
44
import {
@@ -107,6 +110,7 @@ export {
107
110
108
111
import * as Scheduler from './Scheduler' ;
109
112
import { setSuppressWarning } from 'shared/consoleWithStackDev' ;
113
+ import { disableLogs , reenableLogs } from 'shared/ConsolePatchingDev' ;
110
114
111
115
type OpaqueRoot = FiberRoot ;
112
116
@@ -717,14 +721,23 @@ export function getIsStrictModeForDevtools() {
717
721
}
718
722
719
723
export 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
- }
727
724
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
+ }
728
741
}
729
742
730
743
export function injectIntoDevTools ( devToolsConfig : DevToolsConfig ) : boolean {
0 commit comments