Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] don't patch console during first render #22308

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
222 changes: 172 additions & 50 deletions packages/react-devtools-shared/src/__tests__/console-test.js

Large diffs are not rendered by default.

337 changes: 200 additions & 137 deletions packages/react-devtools-shared/src/backend/console.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/react-devtools-shared/src/backend/legacy/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,10 @@ export function attach(
// Not implemented
}

function patchConsoleForStrictMode() {}

function unpatchConsoleForStrictMode() {}

return {
clearErrorsAndWarnings,
clearErrorsForFiberID,
Expand Down Expand Up @@ -1101,6 +1105,7 @@ export function attach(
overrideSuspense,
overrideValueAtPath,
renamePath,
patchConsoleForStrictMode,
prepareViewAttributeSource,
prepareViewElementSource,
renderer,
Expand All @@ -1109,6 +1114,7 @@ export function attach(
startProfiling,
stopProfiling,
storeAsGlobal,
unpatchConsoleForStrictMode,
updateComponentFilters,
};
}
4 changes: 4 additions & 0 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import {inspectHooksOfFiber} from 'react-debug-tools';
import {
patch as patchConsole,
registerRenderer as registerRendererWithConsole,
patchForStrictMode as patchConsoleForStrictMode,
unpatchForStrictMode as unpatchConsoleForStrictMode,
} from './console';
import {
CONCURRENT_MODE_NUMBER,
Expand Down Expand Up @@ -4249,6 +4251,7 @@ export function attach(
handlePostCommitFiberRoot,
inspectElement,
logElementToConsole,
patchConsoleForStrictMode,
prepareViewAttributeSource,
prepareViewElementSource,
overrideError,
Expand All @@ -4261,6 +4264,7 @@ export function attach(
startProfiling,
stopProfiling,
storeAsGlobal,
unpatchConsoleForStrictMode,
updateComponentFilters,
};
}
7 changes: 5 additions & 2 deletions packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ export type ReactRenderer = {
// Only injected by React v16.9+ in DEV mode.
// Enables DevTools to append owners-only component stack to error messages.
getCurrentFiber?: () => Fiber | null,

getIsStrictMode?: () => boolean,
// 17.0.2+
reconcilerVersion?: string,
// Uniquely identifies React DOM v15.
Expand Down Expand Up @@ -352,6 +350,7 @@ export type RendererInterface = {
path: Array<string | number>,
value: any,
) => void,
patchConsoleForStrictMode: () => void,
prepareViewAttributeSource: (
id: number,
path: Array<string | number>,
Expand All @@ -374,6 +373,7 @@ export type RendererInterface = {
path: Array<string | number>,
count: number,
) => void,
unpatchConsoleForStrictMode: () => void,
updateComponentFilters: (componentFilters: Array<ComponentFilter>) => void,
...
};
Expand Down Expand Up @@ -408,5 +408,8 @@ export type DevToolsHook = {
// Added in v16.9 to support Fast Refresh
didError?: boolean,
) => void,

// Testing
dangerous_setTargetConsoleForTesting?: (fakeConsole: Object) => void,
...
};
Loading