Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 15 additions & 27 deletions packages/react-reconciler/src/ReactFiberDevToolsHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

Check failure on line 40 in packages/react-reconciler/src/ReactFiberDevToolsHook.js

View workflow job for this annotation

GitHub Actions / Run eslint

'disableLogs' is defined but never used

Check failure on line 40 in packages/react-reconciler/src/ReactFiberDevToolsHook.js

View workflow job for this annotation

GitHub Actions / Run eslint

'reenableLogs' is defined but never used

declare const __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;

Expand Down Expand Up @@ -188,36 +187,25 @@
}

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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of this hack at some point. I don't think it was meant to survive the roll out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll fix that outside this diff now that I branched off it


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
Loading