react icon indicating copy to clipboard operation
react copied to clipboard

refactor[react-devtools]: move console patching to global hook

Open hoxyq opened this issue 1 year ago • 1 comments

Stacked on https://github.com/facebook/react/pull/30566 and whats under it. See this commit.

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.

hoxyq avatar Aug 05 '24 17:08 hoxyq

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 5:08pm

vercel[bot] avatar Aug 05 '24 17:08 vercel[bot]