-
Notifications
You must be signed in to change notification settings - Fork 49.4k
[DevTools] find best renderer when inspecting #24665
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
Changes from 2 commits
051a179
29841c9
276fc88
b7d225a
7a6b59f
975601b
48bba78
2e8c6c5
27b6756
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,10 @@ import type { | |
RendererInterface, | ||
} from './types'; | ||
import type {ComponentFilter} from '../types'; | ||
import {isSynchronousXHRSupported} from './utils'; | ||
import { | ||
isSynchronousXHRSupported, | ||
getBestMatchingRendererInterface, | ||
} from './utils'; | ||
import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools'; | ||
|
||
const debug = (methodName, ...args) => { | ||
|
@@ -310,20 +313,16 @@ export default class Agent extends EventEmitter<{| | |
} | ||
|
||
getIDForNode(node: Object): number | null { | ||
const renderers = []; | ||
for (const rendererID in this._rendererInterfaces) { | ||
const renderer = ((this._rendererInterfaces[ | ||
(rendererID: any) | ||
]: any): RendererInterface); | ||
|
||
try { | ||
const id = renderer.getFiberIDForNative(node, true); | ||
if (id !== null) { | ||
return id; | ||
} | ||
} catch (error) { | ||
// Some old React versions might throw if they can't find a match. | ||
// If so we should ignore it... | ||
} | ||
renderers.push(renderer); | ||
} | ||
const rendererInterface = getBestMatchingRendererInterface(renderers, node); | ||
if (rendererInterface != null) { | ||
return rendererInterface.getFiberIDForNative(node, true); | ||
|
||
} | ||
return null; | ||
} | ||
|
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.
This probably should be in the
backend/agent
file instead of the utils because you're using two for loops right now and if you put the code fromgetBestMatchingRendererInterface
into the agent you would only need oneex.
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.
The first for-loop is only there for proper typing. Maybe I should refactor the types of
this._rendererInterfaces
?It's indeed easier to do everything
agent
, but how about the use of the util function inOverlay
?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 updated the file with better typing d0346ff so that I can use
values()
instead of for-loop 9a7e0beDoes it make sense?