dillon1000/react
Commit
Browse files refactor[react-devtools]: move console patching to global hook (#30596)
Stacked on https://github.com/facebook/react/pull/30566 and whats under it. See [this commit](https://github.com/facebook/react/pull/30596/commits/374fd737e4b0b7028afb765838db7c0e22def865). It is mostly copying code from one place to another and updating tests. With these changes, for every console method that we patch, there is going to be a single applied patch: - For `error`, `warn`, and `trace` we are patching when hook is installed. This guarantees that component stacks are going to be appended even if browser DevTools are not opened. We pay some price for it, though: if user has browser DevTools closed and if at this point some warning or error is emitted (logged), the next time user opens browser DevTools, they are going to see `hook.js` as the source frame. Unfortunately, ignore listing from source maps is not applied retroactively, and I don't know if its a bug or just a design limitations. Once browser DevTools are opened, source maps will be loaded and ignore listing will be applied for all emitted logs in the future. - For `log`, `info`, `group`, `groupCollapsed` we are only patching when React notifies React DevTools about running in StrictMode. We unpatch the methods right after it.
Changed paths13 files
First-parent comparisonpackages/react-devtools-core/src/backend.js ModifiedM packages/react-devtools-inline/src/backend.js ModifiedM packages/react-devtools-shared/src/__tests__/componentStacks-test.js ModifiedM packages/react-devtools-shared/src/__tests__/console-test.js ModifiedM packages/react-devtools-shared/src/__tests__/setupTests.js ModifiedM packages/react-devtools-shared/src/backend/agent.js ModifiedM packages/react-devtools-shared/src/backend/console.js ModifiedM packages/react-devtools-shared/src/backend/fiber/renderer.js ModifiedM packages/react-devtools-shared/src/backend/flight/renderer.js ModifiedM packages/react-devtools-shared/src/backend/legacy/renderer.js ModifiedM packages/react-devtools-shared/src/backend/types.js ModifiedM packages/react-devtools-shared/src/bridge.js ModifiedM packages/react-devtools-shared/src/hook.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…