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
[Fresh] Support DevTools v3 #17840
[Fresh] Support DevTools v3 #17840
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3af7ef5:
|
Details of bundled changes.Comparing: 3bd6adc...3af7ef5 react-refresh
Size changes (stable) |
Details of bundled changes.Comparing: 3bd6adc...3af7ef5 react-refresh
Size changes (experimental) |
@@ -472,7 +472,8 @@ export function injectIntoGlobalHook(globalObject: any): void { | |||
// Do the same for any already injected roots. | |||
// This is useful if ReactDOM has already been initialized. | |||
// https://github.com/facebook/react/issues/17626 | |||
hook.renderers.forEach((injected, id) => { | |||
const renderers = hook.renderers || hook._renderers; // DevTools v4 || v3 | |||
renderers.forEach((injected, id) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In v4, renderers
is a Map
but in v3 _renderers
is an Object
. So .forEach()
wouldn't work on v3. You'd need to do a different loop for v3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admire your diligence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems okay? ¯\_(ツ)_/¯
@gaearon can possible |
Yes, |
JavaScript is so fishy... thanks I learned that |
@@ -472,7 +472,18 @@ export function injectIntoGlobalHook(globalObject: any): void { | |||
// Do the same for any already injected roots. | |||
// This is useful if ReactDOM has already been initialized. | |||
// https://github.com/facebook/react/issues/17626 | |||
hook.renderers.forEach((injected, id) => { | |||
let renderers = hook.renderers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let renderers = hook.renderers; | |
let { renderers } = hook; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a big fan of destructuring assignment approach. The former code snippet appears kinda redundant atleast IMO.
Flow want something. I'll get back to this maybe. |
I haven't verified but I think this would fix the issue we've seen with the old version of the global hook.