Skip to content

Commit

Permalink
Remove consoleManagedByDevToolsDuringStrictMode (#31755)
Browse files Browse the repository at this point in the history
This is enabled everywhere except the test renderers, which don't use
it.
  • Loading branch information
rickhanlonii authored Dec 13, 2024
1 parent a7b8295 commit 4dff0e6
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 449 deletions.
43 changes: 15 additions & 28 deletions packages/react-reconciler/src/ReactFiberDevToolsHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type DevToolsProfilingHooks = any;

import {DidCapture} from './ReactFiberFlags';
import {
consoleManagedByDevToolsDuringStrictMode,
enableProfilerTimer,
enableSchedulingProfiler,
} from 'shared/ReactFeatureFlags';
Expand All @@ -38,7 +37,6 @@ import {
unstable_setDisableYieldValue,
} from './Scheduler';
import {setSuppressWarning} from 'shared/consoleWithStackDev';
import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';

declare const __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;

Expand Down Expand Up @@ -188,36 +186,25 @@ export function onCommitUnmount(fiber: Fiber) {
}

export function setIsStrictModeForDevtools(newIsStrictMode: boolean) {
if (consoleManagedByDevToolsDuringStrictMode) {
if (typeof log === 'function') {
// We're in a test because Scheduler.log only exists
// in SchedulerMock. To reduce the noise in strict mode tests,
// suppress warnings and disable scheduler yielding during the double render
unstable_setDisableYieldValue(newIsStrictMode);
setSuppressWarning(newIsStrictMode);
}
if (typeof log === 'function') {
// We're in a test because Scheduler.log only exists
// in SchedulerMock. To reduce the noise in strict mode tests,
// suppress warnings and disable scheduler yielding during the double render
unstable_setDisableYieldValue(newIsStrictMode);
setSuppressWarning(newIsStrictMode);
}

if (injectedHook && typeof injectedHook.setStrictMode === 'function') {
try {
injectedHook.setStrictMode(rendererID, newIsStrictMode);
} catch (err) {
if (__DEV__) {
if (!hasLoggedError) {
hasLoggedError = true;
console.error(
'React instrumentation encountered an error: %s',
err,
);
}
if (injectedHook && typeof injectedHook.setStrictMode === 'function') {
try {
injectedHook.setStrictMode(rendererID, newIsStrictMode);
} catch (err) {
if (__DEV__) {
if (!hasLoggedError) {
hasLoggedError = true;
console.error('React instrumentation encountered an error: %s', err);
}
}
}
} else {
if (newIsStrictMode) {
disableLogs();
} else {
reenableLogs();
}
}
}

Expand Down
Loading

0 comments on commit 4dff0e6

Please sign in to comment.